Skip to content

Commit 699aad6

Browse files
committed
init
Signed-off-by: yxia216 <[email protected]>
1 parent 502d8ad commit 699aad6

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

internal/apischema/openai/openai.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,8 @@ type Model struct {
14981498
OwnedBy string `json:"owned_by"`
14991499
}
15001500

1501-
// EmbeddingRequest represents a request structure for embeddings API.
1502-
type EmbeddingRequest struct {
1501+
// EmbeddingCompletionRequest represents a request structure for embeddings API.
1502+
type EmbeddingCompletionRequest struct {
15031503
// Input: Input text to embed, encoded as a string or array of tokens.
15041504
// To embed multiple inputs in a single request, pass an array of strings or array of token arrays.
15051505
// The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002),
@@ -1525,6 +1525,35 @@ type EmbeddingRequest struct {
15251525
User *string `json:"user,omitempty"`
15261526
}
15271527

1528+
// EmbeddingChatRequest represents a request structure for embeddings API. This is not a standard openai, but just extend the request to have messages/chat like completion requests
1529+
type EmbeddingChatRequest struct {
1530+
// Messages: A list of messages comprising the conversation so far.
1531+
// Depending on the model you use, different message types (modalities) are supported,
1532+
// like text, images, and audio.
1533+
Messages []ChatCompletionMessageParamUnion `json:"messages"`
1534+
1535+
// Model: ID of the model to use.
1536+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-model
1537+
Model string `json:"model"`
1538+
1539+
// EncodingFormat: The format to return the embeddings in. Can be either float or base64.
1540+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-encoding_format
1541+
EncodingFormat *string `json:"encoding_format,omitempty"` //nolint:tagliatelle //follow openai api
1542+
1543+
// Dimensions: The number of dimensions the resulting output embeddings should have.
1544+
// Only supported in text-embedding-3 and later models.
1545+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions
1546+
Dimensions *int `json:"dimensions,omitempty"`
1547+
1548+
// User: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
1549+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-user
1550+
User *string `json:"user,omitempty"`
1551+
}
1552+
1553+
type EmbedddingRequest interface {
1554+
EmbeddingCompletionRequest | EmbeddingChatRequest
1555+
}
1556+
15281557
// EmbeddingResponse represents a response from /v1/embeddings.
15291558
// https://platform.openai.com/docs/api-reference/embeddings/object
15301559
type EmbeddingResponse struct {

0 commit comments

Comments
 (0)