feat: version ai result schemas
This commit is contained in:
@@ -38,11 +38,14 @@ type Usage struct {
|
||||
TotalTokens int `json:"total_tokens"`
|
||||
}
|
||||
|
||||
const ChatResultSchemaVersion = "ai.chat_result.v1"
|
||||
|
||||
type ChatResult struct {
|
||||
Content string `json:"content"`
|
||||
Model string `json:"model"`
|
||||
Usage *Usage `json:"usage,omitempty"`
|
||||
DurationMS int64 `json:"duration_ms"`
|
||||
SchemaVersion string `json:"schema_version"`
|
||||
Content string `json:"content"`
|
||||
Model string `json:"model"`
|
||||
Usage *Usage `json:"usage,omitempty"`
|
||||
DurationMS int64 `json:"duration_ms"`
|
||||
}
|
||||
|
||||
type chatRequest struct {
|
||||
@@ -137,10 +140,11 @@ func (c *Client) Chat(ctx context.Context, in ChatInput) (*ChatResult, error) {
|
||||
modelName = c.model
|
||||
}
|
||||
return &ChatResult{
|
||||
Content: out.Choices[0].Message.Content,
|
||||
Model: modelName,
|
||||
Usage: out.Usage,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
SchemaVersion: ChatResultSchemaVersion,
|
||||
Content: out.Choices[0].Message.Content,
|
||||
Model: modelName,
|
||||
Usage: out.Usage,
|
||||
DurationMS: duration.Milliseconds(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user