openai_struct/models/create_embedding_request.rs
1/*
2 * OpenAI API
3 *
4 * The OpenAI REST API. Please see pub https:///platform.openai.com/docs/api-reference for more details.
5 *
6 * OpenAPI spec pub version: 2.3.0
7 *
8 * Generated pub by: https:///github.com/swagger-api/swagger-codegen.git
9 */
10
11#[allow(unused_imports)]
12use serde_json::Value;
13
14/// # on openapi.yaml
15///
16/// ```yaml
17/// CreateEmbeddingRequest:
18/// type: object
19/// additionalProperties: false
20/// properties:
21/// input:
22/// description: |
23/// Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https:///cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. Some models may also impose a limit on total number of tokens summed across inputs.
24/// example: The quick brown fox jumped over the lazy dog
25/// oneOf:
26/// - type: string
27/// title: string
28/// description: The string that will be turned into an embedding.
29/// default: ""
30/// example: This is a test.
31/// - type: array
32/// title: array
33/// description: The array of strings that will be turned into an embedding.
34/// minItems: 1
35/// maxItems: 2048
36/// items:
37/// type: string
38/// default: ""
39/// example: "['This is a test.']"
40/// - type: array
41/// title: array
42/// description: The array of integers that will be turned into an embedding.
43/// minItems: 1
44/// maxItems: 2048
45/// items:
46/// type: integer
47/// example: "[1212, 318, 257, 1332, 13]"
48/// - type: array
49/// title: array
50/// description:
51/// The array of arrays containing integers that will be turned into an
52/// embedding.
53/// minItems: 1
54/// maxItems: 2048
55/// items:
56/// type: array
57/// minItems: 1
58/// items:
59/// type: integer
60/// example: "[[1212, 318, 257, 1332, 13]]"
61/// model:
62/// description: >
63/// ID of the model to use. You can use the [List
64/// models](/docs/api-reference/models/list) API to see all of your
65/// available models, or see our [Model overview](/docs/models) for
66/// descriptions of them.
67/// example: text-embedding-3-small
68/// anyOf:
69/// - type: string
70/// - type: string
71/// enum:
72/// - text-embedding-ada-002
73/// - text-embedding-3-small
74/// - text-embedding-3-large
75/// x-oaiTypeLabel: string
76/// encoding_format:
77/// description:
78/// The format to return the embeddings in. Can be either `float` or
79/// [`base64`](https:///pypi.org/project/pybase64/).
80/// example: float
81/// default: float
82/// type: string
83/// enum:
84/// - float
85/// - base64
86/// dimensions:
87/// description: >
88/// The number of dimensions the resulting output embeddings should
89/// have. Only supported in `text-embedding-3` and later models.
90/// type: integer
91/// minimum: 1
92/// user:
93/// type: string
94/// example: user-1234
95/// description: >
96/// A unique identifier representing your end-user, which can help
97/// OpenAI to monitor and detect abuse. [Learn
98/// more](/docs/guides/safety-best-practices#end-user-ids).
99/// required:
100/// - model
101/// - input
102/// ```
103#[derive(Debug, Serialize, Deserialize)]
104pub struct CreateEmbeddingRequest {
105 /// The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.
106 #[serde(rename = "dimensions")]
107 pub dimensions: Option<i32>,
108 /// The format to return the embeddings in. Can be either `float` or [`base64`](https:///pypi.org/project/pybase64/).
109 #[serde(rename = "encoding_format")]
110 pub encoding_format: Option<String>,
111 /// Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or fewer. [Example Python code](https:///cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. Some models may also impose a limit on total number of tokens summed across inputs.
112 #[serde(rename = "input")]
113 pub input: CreateEmbeddingRequestInput,
114 /// ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models) for descriptions of them.
115 ///
116 /// - text-embedding-ada-002
117 /// - text-embedding-3-small
118 /// - text-embedding-3-large
119 #[serde(rename = "model")]
120 pub model: String,
121 /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
122 #[serde(rename = "user")]
123 pub user: Option<String>,
124}
125
126#[derive(Debug, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum CreateEmbeddingRequestInput {
129 /// The string that will be turned into an embedding. example: This is a test.
130 Text(String),
131 /// The array of strings that will be turned into an embedding. example: "['This is a test.']"
132 Texts(Vec<String>),
133 /// The array of integers that will be turned into an embedding. example: "[1212, 318, 257, 1332, 13]"
134 Embedding(Vec<isize>),
135 /// The array of arrays containing integers that will be turned into an embedding. example: "[[1212, 318, 257, 1332, 13]]"
136 Embeddings(Vec<Vec<isize>>),
137}