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
This commit is contained in:
parent
f561eecfb8
commit
6f133a0bdd
1 changed files with 13 additions and 3 deletions
|
@ -164,9 +164,15 @@ type ListCompletion struct {
|
|||
}
|
||||
|
||||
type EmbeddingList struct {
|
||||
Object string `json:"object"`
|
||||
Data []Embedding `json:"data"`
|
||||
Model string `json:"model"`
|
||||
Object string `json:"object"`
|
||||
Data []Embedding `json:"data"`
|
||||
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 {
|
||||
|
@ -332,6 +338,10 @@ func toEmbeddingList(model string, r api.EmbedResponse) EmbeddingList {
|
|||
Object: "list",
|
||||
Data: data,
|
||||
Model: model,
|
||||
Usage: EmbeddingUsage{
|
||||
PromptTokens: r.PromptEvalCount,
|
||||
TotalTokens: r.PromptEvalCount,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue