Unverified Commit 6f133a0b authored by royjhan's avatar royjhan Committed by GitHub
Browse files

OpenAI: Add Usage to `v1/embeddings` (#5886)

* add prompt tokens to embed response

* rm slog

* metrics

* types

* prompt n

* clean up

* reset submodule

* add tokens to v1/embeddings

* separate usage
parent f561eecf
...@@ -164,9 +164,15 @@ type ListCompletion struct { ...@@ -164,9 +164,15 @@ type ListCompletion struct {
} }
type EmbeddingList struct { type EmbeddingList struct {
Object string `json:"object"` Object string `json:"object"`
Data []Embedding `json:"data"` Data []Embedding `json:"data"`
Model string `json:"model"` Model string `json:"model"`
Usage EmbeddingUsage `json:"usage,omitempty"`
}
type EmbeddingUsage struct {
PromptTokens int `json:"prompt_tokens"`
TotalTokens int `json:"total_tokens"`
} }
func NewError(code int, message string) ErrorResponse { func NewError(code int, message string) ErrorResponse {
...@@ -332,6 +338,10 @@ func toEmbeddingList(model string, r api.EmbedResponse) EmbeddingList { ...@@ -332,6 +338,10 @@ func toEmbeddingList(model string, r api.EmbedResponse) EmbeddingList {
Object: "list", Object: "list",
Data: data, Data: data,
Model: model, Model: model,
Usage: EmbeddingUsage{
PromptTokens: r.PromptEvalCount,
TotalTokens: r.PromptEvalCount,
},
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment