Documentation
¶
Index ¶
- Variables
- func ExtractJSON(text string) string
- func RegisterModelProvider(name string, factory ModelProviderFactory)
- type ChatStream
- type ChatStreamOutput
- type ContentBlock
- type ContentBlockText
- type ConversationRequest
- type ConversationResponse
- type ConversationRole
- type Message
- type ModelProvider
- type ModelProviderConfig
- type ModelProviderFactory
- type ModelUsage
- type StopReason
- type StreamChunk
- type StreamChunkContent
- type StreamChunkError
- type StreamChunkStop
- type StreamChunkUsage
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnknownProvider = errors.New("unknown ai provider")
)
Functions ¶
func ExtractJSON ¶
func RegisterModelProvider ¶
func RegisterModelProvider(name string, factory ModelProviderFactory)
Types ¶
type ChatStream ¶
type ChatStream interface {
Events() <-chan StreamChunk
}
type ChatStreamOutput ¶
type ChatStreamOutput interface {
GetStream() ChatStream
}
type ContentBlock ¶
type ContentBlock interface {
// contains filtered or unexported methods
}
type ContentBlockText ¶
type ContentBlockText struct {
Value string `json:"value"`
}
type ConversationRequest ¶
type ConversationRequest struct {
ModelId string `json:"modelId"`
System string `json:"system,omitempty"`
Messages []Message `json:"messages"`
MaxTokens int `json:"maxTokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
Reasoning bool `json:"reasoning,omitempty"`
JsonResponse bool `json:"requireJson,omitempty"`
}
type ConversationResponse ¶
type ConversationResponse struct {
ProviderName string `json:"providerName,omitempty"`
ModelId string `json:"modelId,omitempty"`
Content []ContentBlock `json:"content"`
StopReason StopReason `json:"stopReason,omitempty"`
Usage *ModelUsage `json:"usage,omitempty"`
}
type ConversationRole ¶
type ConversationRole string
const ( UserRole ConversationRole = "user" AssistantRole ConversationRole = "assistant" )
type Message ¶
type Message struct {
Role ConversationRole `json:"role"`
Content []ContentBlock `json:"content"`
}
type ModelProvider ¶
type ModelProvider interface {
GetName() string
CostEstimate(modelId string, usage ModelUsage) float64
Chat(ctx context.Context, req *ConversationRequest) (*ConversationResponse, error)
ChatStream(ctx context.Context, req *ConversationRequest) (ChatStreamOutput, error)
}
func NewModelProvider ¶
func NewModelProvider(config ModelProviderConfig) (ModelProvider, error)
type ModelProviderConfig ¶
type ModelProviderFactory ¶
type ModelProviderFactory func(ModelProviderConfig) (ModelProvider, error)
type ModelUsage ¶
type StopReason ¶
type StopReason string
const ( StopReasonStop StopReason = "stop" StopReasonToolCalls StopReason = "toolCalls" StopReasonLength StopReason = "length" )
type StreamChunk ¶
type StreamChunk interface {
// contains filtered or unexported methods
}
type StreamChunkContent ¶
type StreamChunkContent struct {
Content ContentBlock `json:"content"`
}
type StreamChunkError ¶
type StreamChunkError struct {
Error string `json:"error,omitempty"`
}
type StreamChunkStop ¶
type StreamChunkStop struct {
StopReason StopReason `json:"stopReason,omitempty"`
}
type StreamChunkUsage ¶
type StreamChunkUsage struct {
ModelId string `json:"modelId,omitempty"`
Usage *ModelUsage `json:"usage,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.