58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Client interface {
|
|
Generate(ctx context.Context, input GenerateInput) (GenerateResult, error)
|
|
}
|
|
|
|
type GenerateProgress struct {
|
|
Mode string // "streaming", "stream_unsupported", "non_streaming"
|
|
Reason string
|
|
LastEventTime time.Time
|
|
}
|
|
|
|
// WorkspaceMetadata carries workspace-bound authoring context. On the wire,
|
|
// only the Path is serialized as a flat string to metadata.workspace in the
|
|
// /v1/responses payload. Other fields are used on the client-side/authoring
|
|
// logic.
|
|
type WorkspaceMetadata struct {
|
|
Path string `json:"path"`
|
|
SourceBranch string `json:"source_branch,omitempty"`
|
|
Provider string `json:"provider,omitempty"`
|
|
WorkItemID string `json:"work_item_id,omitempty"`
|
|
Tenant string `json:"tenant,omitempty"`
|
|
Project string `json:"project,omitempty"`
|
|
ExternalURL string `json:"external_url,omitempty"`
|
|
StateID string `json:"state_id,omitempty"`
|
|
}
|
|
|
|
type GenerateInput struct {
|
|
Model string
|
|
Instructions string
|
|
Input string
|
|
Metadata map[string]string
|
|
WorkspaceMetadata *WorkspaceMetadata
|
|
MaxOutputTokens int
|
|
Temperature *float64
|
|
TopP *float64
|
|
OnProgress func(GenerateProgress)
|
|
}
|
|
|
|
type GenerateResult struct {
|
|
ID string
|
|
Model string
|
|
Text string
|
|
Usage Usage
|
|
Raw json.RawMessage
|
|
}
|
|
|
|
type Usage struct {
|
|
InputTokens int
|
|
OutputTokens int
|
|
TotalTokens int
|
|
}
|