Documentation
¶
Overview ¶
Package llm provides an abstraction layer for LLM types. This package wraps langchaingo types so that the orchestrator and business logic never import langchaingo directly. The provider layer handles conversion.
Index ¶
- func ToLangChainMessage(msg Message) llms.MessageContent
- func ToLangChainMessages(msgs []Message) []llms.MessageContent
- func ToLangChainOptions(opts *CallOptions) []llms.CallOption
- func ToLangChainTool(tool Tool) llms.Tool
- func ToLangChainTools(tools []Tool) []llms.Tool
- type CallOption
- type CallOptions
- type ContentPart
- type FunctionDef
- type Message
- type MessageRole
- type TextContent
- type Tool
- type ToolCall
- type ToolCallResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToLangChainMessage ¶
func ToLangChainMessage(msg Message) llms.MessageContent
ToLangChainMessage converts a single Message to langchaingo MessageContent.
func ToLangChainMessages ¶
func ToLangChainMessages(msgs []Message) []llms.MessageContent
ToLangChainMessages converts our Message types to langchaingo MessageContent.
func ToLangChainOptions ¶
func ToLangChainOptions(opts *CallOptions) []llms.CallOption
ToLangChainOptions converts our CallOptions to langchaingo CallOptions.
func ToLangChainTool ¶
ToLangChainTool converts a single Tool to langchaingo Tool.
func ToLangChainTools ¶
ToLangChainTools converts our Tool types to langchaingo Tools.
Types ¶
type CallOption ¶
type CallOption func(*CallOptions)
CallOption is a function that modifies CallOptions.
func WithMaxTokens ¶
func WithMaxTokens(tokens int) CallOption
WithMaxTokens sets the max tokens for the LLM call.
func WithTemperature ¶
func WithTemperature(temp float64) CallOption
WithTemperature sets the temperature for the LLM call.
func WithTools ¶
func WithTools(tools []Tool) CallOption
WithTools sets the tools available for the LLM call.
type CallOptions ¶
CallOptions holds the options for an LLM call.
func ApplyOptions ¶
func ApplyOptions(opts ...CallOption) *CallOptions
ApplyOptions applies a list of CallOptions to a CallOptions struct.
type ContentPart ¶
type ContentPart interface {
// contains filtered or unexported methods
}
ContentPart is the interface for message content parts. Implemented by TextContent, ToolCall, and ToolCallResponse.
type FunctionDef ¶
FunctionDef represents a function definition for a tool.
type Message ¶
type Message struct {
Role MessageRole
Parts []ContentPart
}
Message represents a message in an LLM conversation.
type MessageRole ¶
type MessageRole string
MessageRole represents the role of a message in a conversation.
const ( RoleSystem MessageRole = "system" RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" RoleTool MessageRole = "tool" )
func FromLangChainRole ¶
func FromLangChainRole(role llms.ChatMessageType) MessageRole
FromLangChainRole converts langchaingo ChatMessageType to our MessageRole.
type TextContent ¶
type TextContent struct {
Text string
}
TextContent represents text content in a message.
func TextPart ¶
func TextPart(text string) TextContent
TextPart is a helper function to create a TextContent part.
type Tool ¶
type Tool struct {
Type string
Function *FunctionDef
}
Tool represents a tool that can be used by an LLM.
type ToolCall ¶
ToolCall represents a tool call requested by the assistant.
func FromLangChainToolCalls ¶
FromLangChainToolCalls converts langchaingo ToolCalls to our ToolCall type.
type ToolCallResponse ¶
ToolCallResponse represents the result of a tool call.