Skip to content

Commit 71b2589

Browse files
committed
init
Signed-off-by: yxia216 <[email protected]>
1 parent 96a2fdd commit 71b2589

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
@@ -1493,8 +1493,8 @@ type Model struct {
14931493
OwnedBy string `json:"owned_by"`
14941494
}
14951495

1496-
// EmbeddingRequest represents a request structure for embeddings API.
1497-
type EmbeddingRequest struct {
1496+
// EmbeddingCompletionRequest represents a request structure for embeddings API.
1497+
type EmbeddingCompletionRequest struct {
14981498
// Input: Input text to embed, encoded as a string or array of tokens.
14991499
// To embed multiple inputs in a single request, pass an array of strings or array of token arrays.
15001500
// The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002),
@@ -1520,6 +1520,35 @@ type EmbeddingRequest struct {
15201520
User *string `json:"user,omitempty"`
15211521
}
15221522

1523+
// 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
1524+
type EmbeddingChatRequest struct {
1525+
// Messages: A list of messages comprising the conversation so far.
1526+
// Depending on the model you use, different message types (modalities) are supported,
1527+
// like text, images, and audio.
1528+
Messages []ChatCompletionMessageParamUnion `json:"messages"`
1529+
1530+
// Model: ID of the model to use.
1531+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-model
1532+
Model string `json:"model"`
1533+
1534+
// EncodingFormat: The format to return the embeddings in. Can be either float or base64.
1535+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-encoding_format
1536+
EncodingFormat *string `json:"encoding_format,omitempty"` //nolint:tagliatelle //follow openai api
1537+
1538+
// Dimensions: The number of dimensions the resulting output embeddings should have.
1539+
// Only supported in text-embedding-3 and later models.
1540+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions
1541+
Dimensions *int `json:"dimensions,omitempty"`
1542+
1543+
// User: A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
1544+
// Docs: https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-user
1545+
User *string `json:"user,omitempty"`
1546+
}
1547+
1548+
type EmbedddingRequest interface {
1549+
EmbeddingCompletionRequest | EmbeddingChatRequest
1550+
}
1551+
15231552
// EmbeddingResponse represents a response from /v1/embeddings.
15241553
// https://platform.openai.com/docs/api-reference/embeddings/object
15251554
type EmbeddingResponse struct {

0 commit comments

Comments
 (0)