Documentation
¶
Index ¶
- func RenderCMD3(opts RenderCmd3Options) (string, error)
- func RenderCMD4(opts RenderCmd4Options) (string, error)
- type AccumulatedToolCall
- type AggregatedResult
- type CitationQuality
- type Content
- type ContentType
- type Filter
- type FilterCitation
- type FilterOption
- func HandleMultiHop() FilterOption
- func HandleMultiHopCmd3() FilterOption
- func HandleMultiHopCmd4() FilterOption
- func HandleRAG() FilterOption
- func HandleSearchQuery() FilterOption
- func RemoveToken(token string) FilterOption
- func StreamNonGroundedAnswer() FilterOption
- func StreamProcessedParams() FilterOption
- func StreamToolActions() FilterOption
- func WithChunkSize(size int) FilterOption
- func WithExclusiveStops(stops []string) FilterOption
- func WithInclusiveStops(stops []string) FilterOption
- func WithLeftTrimmed() FilterOption
- func WithRightTrimmed() FilterOption
- type FilterOptions
- func (opts *FilterOptions) Cmd3() *FilterOptions
- func (opts *FilterOptions) Cmd4() *FilterOptions
- func (opts *FilterOptions) Free()
- func (opts *FilterOptions) HandleMultiHop() *FilterOptions
- func (opts *FilterOptions) HandleRAG() *FilterOptions
- func (opts *FilterOptions) HandleSearchQuery() *FilterOptions
- func (opts *FilterOptions) RemoveToken(token string) *FilterOptions
- func (opts *FilterOptions) StreamNonGroundedAnswer() *FilterOptions
- func (opts *FilterOptions) StreamProcessedParams() *FilterOptions
- func (opts *FilterOptions) StreamToolActions() *FilterOptions
- func (opts *FilterOptions) WithChunkSize(size int) *FilterOptions
- func (opts *FilterOptions) WithExclusiveStops(stops []string) *FilterOptions
- func (opts *FilterOptions) WithInclusiveStops(stops []string) *FilterOptions
- func (opts *FilterOptions) WithLeftTrimmed() *FilterOptions
- func (opts *FilterOptions) WithRightTrimmed() *FilterOptions
- type FilterToolParameter
- type Grounding
- type Image
- type Message
- type ReasoningType
- type RenderCmd3Options
- type RenderCmd4Options
- type Role
- type SafetyMode
- type SearchQueryDelta
- type Source
- type SyncFilter
- type Tool
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderCMD3 ¶
func RenderCMD3(opts RenderCmd3Options) (string, error)
RenderCMD3 renders CMD3 using the Rust templating engine via FFI.
func RenderCMD4 ¶
func RenderCMD4(opts RenderCmd4Options) (string, error)
RenderCMD4 renders CMD4 using the Rust templating engine via FFI.
Types ¶
type AccumulatedToolCall ¶ added in v0.6.0
type AccumulatedToolCall struct {
Index uint
ID string
Name string
Arguments string
ProcessedParams []FilterToolParameter
}
AccumulatedToolCall represents a tool call (possibly partial in streaming)
type AggregatedResult ¶ added in v0.6.0
type AggregatedResult struct {
Content *string
Reasoning *string
ToolCalls []AccumulatedToolCall
Citations []FilterCitation
SearchQueries []SearchQueryDelta
}
AggregatedResult is the result of a write_decoded or flush_partials call
type CitationQuality ¶
type CitationQuality int32
const ( CitationQualityUnknown CitationQuality = 0 CitationQualityOff CitationQuality = 1 CitationQualityOn CitationQuality = 2 )
func (*CitationQuality) UnmarshalJSON ¶
func (q *CitationQuality) UnmarshalJSON(data []byte) error
type Content ¶
type Content struct {
Type ContentType `json:"type"`
Text string `json:"text,omitempty"` // optional: empty means omitted
Thinking string `json:"thinking,omitempty"` // optional: empty means omitted
Image *Image `json:"image,omitempty"` // optional
Document orderedjson.Object `json:"document,omitempty"`
Multipart []Content `json:"multipart,omitempty"` // optional
}
type ContentType ¶
type ContentType int32
const ( ContentUnknown ContentType = 0 ContentText ContentType = 1 ContentThinking ContentType = 2 ContentImage ContentType = 3 ContentDocument ContentType = 4 ContentMultipart ContentType = 5 )
func (*ContentType) UnmarshalJSON ¶
func (t *ContentType) UnmarshalJSON(data []byte) error
type Filter ¶
type Filter interface {
// WriteDecoded writes a decoded token string to the filter
WriteDecoded(decodedToken string) (*AggregatedResult, error)
// FlushPartials flushes any partial outputs
FlushPartials() (*AggregatedResult, error)
}
Filter is the interface used to parse the output of a cohere model
func NewFilter ¶
func NewFilter(options ...FilterOption) Filter
NewFilter creates a new synchronous filter
type FilterCitation ¶
type FilterCitation struct {
// The beginning index of the citation in the larger generation.
// E.g. "Hello world" where the citation is "world" would have a StartIndex of 6.
StartIndex uint `json:"start_index"`
// The end index of the citation in the larger generation.
// E.g. "Hello world" where the citation is "world" would have an EndIndex of 10.
EndIndex uint `json:"end_index"`
Text string `json:"text"`
Sources []Source `json:"sources"`
IsThinking bool `json:"is_thinking"`
}
FilterCitation represents a citation parsed from a model generation
type FilterOption ¶
type FilterOption func(*filterConfig)
FilterOption is a function that configures a filter
func HandleMultiHop ¶
func HandleMultiHop() FilterOption
HandleMultiHop configures the filter to handle multi-hop format
func HandleMultiHopCmd3 ¶
func HandleMultiHopCmd3() FilterOption
HandleMultiHopCmd3 configures the filter to handle multi-hop CMD3 format
func HandleMultiHopCmd4 ¶
func HandleMultiHopCmd4() FilterOption
HandleMultiHopCmd4 configures the filter to handle multi-hop CMD4 format
func HandleRAG ¶
func HandleRAG() FilterOption
HandleRAG configures the filter to handle RAG (Retrieval Augmented Generation) format
func HandleSearchQuery ¶
func HandleSearchQuery() FilterOption
HandleSearchQuery configures the filter to handle search query format
func RemoveToken ¶
func RemoveToken(token string) FilterOption
RemoveToken removes a specific token from the output
func StreamNonGroundedAnswer ¶
func StreamNonGroundedAnswer() FilterOption
StreamNonGroundedAnswer enables streaming of non-grounded answer
func StreamProcessedParams ¶
func StreamProcessedParams() FilterOption
StreamProcessedParams enables streaming of processed parameters
func StreamToolActions ¶
func StreamToolActions() FilterOption
StreamToolActions enables streaming of tool actions
func WithExclusiveStops ¶
func WithExclusiveStops(stops []string) FilterOption
WithExclusiveStops sets exclusive stop sequences
func WithInclusiveStops ¶
func WithInclusiveStops(stops []string) FilterOption
WithInclusiveStops sets inclusive stop sequences
func WithRightTrimmed ¶
func WithRightTrimmed() FilterOption
WithRightTrimmed enables right trimming
type FilterOptions ¶
type FilterOptions struct {
// contains filtered or unexported fields
}
FilterOptions is the Go wrapper around CFilterOptions
func NewFilterOptions ¶
func NewFilterOptions() *FilterOptions
NewFilterOptions creates a new FilterOptions instance
func (*FilterOptions) Cmd3 ¶
func (opts *FilterOptions) Cmd3() *FilterOptions
Cmd3 configures options for multi-hop CMD3 format
func (*FilterOptions) Cmd4 ¶
func (opts *FilterOptions) Cmd4() *FilterOptions
HandleMultiHopCmd4 configures options for multi-hop CMD4 format
func (*FilterOptions) Free ¶
func (opts *FilterOptions) Free()
Free releases the FilterOptions resources
func (*FilterOptions) HandleMultiHop ¶
func (opts *FilterOptions) HandleMultiHop() *FilterOptions
HandleMultiHop configures options for multi-hop format
func (*FilterOptions) HandleRAG ¶
func (opts *FilterOptions) HandleRAG() *FilterOptions
HandleRAG configures options for RAG format
func (*FilterOptions) HandleSearchQuery ¶
func (opts *FilterOptions) HandleSearchQuery() *FilterOptions
HandleSearchQuery configures options for search query handling
func (*FilterOptions) RemoveToken ¶
func (opts *FilterOptions) RemoveToken(token string) *FilterOptions
RemoveToken removes a specific token from the output
func (*FilterOptions) StreamNonGroundedAnswer ¶
func (opts *FilterOptions) StreamNonGroundedAnswer() *FilterOptions
StreamNonGroundedAnswer enables streaming of non-grounded answer
func (*FilterOptions) StreamProcessedParams ¶
func (opts *FilterOptions) StreamProcessedParams() *FilterOptions
StreamProcessedParams enables streaming of processed parameters
func (*FilterOptions) StreamToolActions ¶
func (opts *FilterOptions) StreamToolActions() *FilterOptions
StreamToolActions enables streaming of tool actions
func (*FilterOptions) WithChunkSize ¶
func (opts *FilterOptions) WithChunkSize(size int) *FilterOptions
WithChunkSize sets the chunk size
func (*FilterOptions) WithExclusiveStops ¶
func (opts *FilterOptions) WithExclusiveStops(stops []string) *FilterOptions
WithExclusiveStops sets exclusive stop sequences
func (*FilterOptions) WithInclusiveStops ¶
func (opts *FilterOptions) WithInclusiveStops(stops []string) *FilterOptions
WithInclusiveStops sets inclusive stop sequences
func (*FilterOptions) WithLeftTrimmed ¶
func (opts *FilterOptions) WithLeftTrimmed() *FilterOptions
WithLeftTrimmed enables left trimming
func (*FilterOptions) WithRightTrimmed ¶
func (opts *FilterOptions) WithRightTrimmed() *FilterOptions
WithRightTrimmed enables right trimming
type FilterToolParameter ¶
FilterToolParameter represents a change to a tool parameter
type Message ¶
type Message struct {
Role Role `json:"role"`
Content []Content `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"` // optional: empty means omitted
Citations []FilterCitation `json:"citations,omitempty"`
}
type ReasoningType ¶
type ReasoningType int32
const ( ReasoningTypeUnknown ReasoningType = 0 ReasoningTypeEnabled ReasoningType = 1 ReasoningTypeDisabled ReasoningType = 2 )
func (*ReasoningType) UnmarshalJSON ¶
func (rt *ReasoningType) UnmarshalJSON(data []byte) error
type RenderCmd3Options ¶
type RenderCmd3Options struct {
Messages []Message `json:"messages"`
TemplateID *string `json:"template_id,omitempty"`
Template string `json:"template"`
TemplateJinja string `json:"template_jinja"`
UseJinja bool `json:"use_jinja"`
DevInstruction *string `json:"dev_instruction,omitempty"`
Documents []orderedjson.Object `json:"documents,omitempty"` // JSON objects
AvailableTools []Tool `json:"available_tools,omitempty"`
SafetyMode *SafetyMode `json:"safety_mode,omitempty"` // optional
CitationQuality *CitationQuality `json:"citation_quality,omitempty"` // optional
ReasoningType *ReasoningType `json:"reasoning_type,omitempty"` // optional
SkipPreamble bool `json:"skip_preamble,omitempty"`
ResponsePrefix *string `json:"response_prefix,omitempty"`
JSONSchema *string `json:"json_schema,omitempty"`
JSONMode bool `json:"json_mode,omitempty"`
AdditionalTemplateFields map[string]any `json:"additional_template_fields,omitempty"` // optional: JSON-encoded
EscapedSpecialTokens map[string]string `json:"escaped_special_tokens,omitempty"` // optional: JSON-encoded
}
type RenderCmd4Options ¶
type RenderCmd4Options struct {
Messages []Message `json:"messages"`
TemplateID *string `json:"template_id,omitempty"`
Template string `json:"template"`
TemplateJinja string `json:"template_jinja"`
UseJinja bool `json:"use_jinja"`
DevInstruction *string `json:"dev_instruction,omitempty"`
PlatformInstruction *string `json:"platform_instruction,omitempty"`
Documents []orderedjson.Object `json:"documents,omitempty"`
AvailableTools []Tool `json:"available_tools,omitempty"`
Grounding *Grounding `json:"grounding,omitempty"` // optional
ResponsePrefix *string `json:"response_prefix,omitempty"`
JSONSchema *string `json:"json_schema,omitempty"`
JSONMode bool `json:"json_mode,omitempty"`
AdditionalTemplateFields map[string]any `json:"additional_template_fields,omitempty"` // optional
EscapedSpecialTokens map[string]string `json:"escaped_special_tokens,omitempty"` // optional
}
type SafetyMode ¶
type SafetyMode int32
const ( SafetyModeUnknown SafetyMode = 0 SafetyModeNone SafetyMode = 1 SafetyModeStrict SafetyMode = 2 SafetyModeContextual SafetyMode = 3 )
func (*SafetyMode) UnmarshalJSON ¶
func (s *SafetyMode) UnmarshalJSON(data []byte) error
type SearchQueryDelta ¶ added in v0.6.0
SearchQueryDelta represents a search query update
type Source ¶
type Source struct {
ToolCallIndex uint `json:"tool_call_index"`
ToolResultIndices []uint `json:"tool_result_indices"`
}
Source indicates which tool call and which tool results from that tool are being cited
type SyncFilter ¶
type SyncFilter struct {
// contains filtered or unexported fields
}
SyncFilter is a synchronous filter implementation
func (*SyncFilter) FlushPartials ¶
func (f *SyncFilter) FlushPartials() (*AggregatedResult, error)
FlushPartials flushes any partial outputs
func (*SyncFilter) WriteDecoded ¶
func (f *SyncFilter) WriteDecoded(decodedToken string) (*AggregatedResult, error)
WriteDecoded writes a decoded token string to the filter