Documentation
¶
Index ¶
- Constants
- Variables
- type BlockThreshold
- type ChatContext
- type Config
- type Content
- type FileData
- type FinishReason
- type FunctionCall
- type FunctionDeclaration
- type FunctionResponse
- type InlineData
- type Model
- type OpenAPIType
- type Role
- type Schema
- type Segment
- type SegmentType
- type StreamContent
- type Text
- type ThinkingBlock
- type ThinkingConfig
- type UsageData
Constants ¶
View Source
const ( RoleUser = Role("user") RoleModel = Role("model") RoleFunc = Role("function") )
View Source
const ( FinishReasonUnknown = FinishReason("unknown") FinishReasonError = FinishReason("error") FinishReasonSafety = FinishReason("safety") FinishReasonRecitation = FinishReason("recitation") FinishReasonStop = FinishReason("stop") FinishReasonMaxTokens = FinishReason("max_tokens") FinishReasonToolUse = FinishReason("tool_use") )
Variables ¶
View Source
var ( ErrUnknown = errors.New("unknown error") ErrNoResponse = errors.New("no response") ErrInvalidRequest = errors.New("invalid request") ErrInvalidResponse = errors.New("invalid response") ErrAuthentication = errors.New("authentication error") ErrPermission = errors.New("permission error") ErrNotFound = errors.New("not found") ErrRateLimit = errors.New("rate limit error") ErrOverloaded = errors.New("overloaded") ErrInternalServer = errors.New("internal server error") )
Functions ¶
This section is empty.
Types ¶
type BlockThreshold ¶
type BlockThreshold uint16
const ( BlockDefault BlockThreshold = iota BlockNone BlockLowAndAbove BlockMediumAndAbove BlockOnlyHigh BlockOff )
type ChatContext ¶
type ChatContext struct {
Contents []*Content `json:"contents"`
Tools []*FunctionDeclaration `json:"tools"`
SystemInstruction string `json:"system_instruction"`
}
type Config ¶
type Config struct {
Temperature *float32 `json:"temperature,omitempty"`
TopP *float32 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
ThinkingConfig *ThinkingConfig `json:"thinking_config,omitempty"`
SystemInstruction string `json:"system_instruction,omitempty"`
SafetyFilterThreshold BlockThreshold `json:"filter_threshold,omitempty"`
}
type Content ¶
func TextContent ¶
type FinishReason ¶
type FinishReason string
type FunctionCall ¶
type FunctionCall struct {
Name string `json:"name"`
ID string `json:"id"`
Args map[string]interface{} `json:"args"`
}
func (*FunctionCall) Segment ¶
func (*FunctionCall) Segment()
func (*FunctionCall) Type ¶
func (*FunctionCall) Type() SegmentType
type FunctionDeclaration ¶
type FunctionResponse ¶
type FunctionResponse struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
Content interface{} `json:"content"`
IsError bool `json:"-"`
}
func (*FunctionResponse) Segment ¶
func (*FunctionResponse) Segment()
func (*FunctionResponse) Type ¶
func (*FunctionResponse) Type() SegmentType
type InlineData ¶
func (*InlineData) Segment ¶
func (*InlineData) Segment()
func (*InlineData) Type ¶
func (*InlineData) Type() SegmentType
type Model ¶
type Model interface {
GenerateStream(ctx context.Context, chat *ChatContext, input *Content) *StreamContent
Close() error
Name() string
}
type OpenAPIType ¶
type OpenAPIType string
const ( OpenAPITypeString OpenAPIType = "string" OpenAPITypeNumber OpenAPIType = "number" OpenAPITypeInteger OpenAPIType = "integer" OpenAPITypeBoolean OpenAPIType = "boolean" OpenAPITypeArray OpenAPIType = "array" OpenAPITypeObject OpenAPIType = "object" )
type Schema ¶
type Schema struct {
Type OpenAPIType `json:"type"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Items *Schema `json:"items,omitempty"`
Required []string `json:"required,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Format string `json:"format,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
}
type Segment ¶
type Segment interface {
Segment()
Type() SegmentType
}
type SegmentType ¶
type SegmentType uint16
const ( SegmentTypeUnknown SegmentType = iota // unknown SegmentTypeText // text SegmentTypeInlineData // inline_data SegmentTypeFileData // file_data SegmentTypeFunctionCall // function_call SegmentTypeFunctionResponse // function_response SegmentTypeThinkingBlock // thinking_block )
func (SegmentType) String ¶
func (i SegmentType) String() string
type StreamContent ¶
type StreamContent struct {
Err error `json:"error"` // Only Available after Stream channel is closed
Content *Content `json:"content"` // Only Available after Stream channel is closed
UsageData *UsageData `json:"usageData"` // Only Available after Stream channel is closed (Note: UsageData is not available for all LLM providers)
FinishReason FinishReason `json:"finishReason"` // Only Available after Stream channel is closed
Stream <-chan Segment `json:"-"` // Response Stream
}
func (*StreamContent) Text ¶
func (g *StreamContent) Text() string
Text returns the text content of the segment. Note: This function must be called after the Stream channel is closed.
func (*StreamContent) Wait ¶
func (g *StreamContent) Wait() error
type ThinkingBlock ¶ added in v0.2.1
type ThinkingBlock struct {
Redacted bool `json:"redacted,omitempty"`
Signature string `json:"signature,omitempty"`
Data string `json:"content,omitempty"`
}
func (*ThinkingBlock) Segment ¶ added in v0.2.1
func (*ThinkingBlock) Segment()
func (*ThinkingBlock) Type ¶ added in v0.2.1
func (*ThinkingBlock) Type() SegmentType
type ThinkingConfig ¶
Click to show internal directories.
Click to hide internal directories.