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
|
@ -167,6 +167,12 @@ 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 {
|
||||||
Object: "list",
|
Object: "list",
|
||||||
Data: data,
|
Data: data,
|
||||||
Model: model,
|
Model: model,
|
||||||
|
Usage: EmbeddingUsage{
|
||||||
|
PromptTokens: r.PromptEvalCount,
|
||||||
|
TotalTokens: r.PromptEvalCount,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue