llm

package
v0.0.0-...-36d6306 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

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

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

func ToLangChainTool(tool Tool) llms.Tool

ToLangChainTool converts a single Tool to langchaingo Tool.

func ToLangChainTools

func ToLangChainTools(tools []Tool) []llms.Tool

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

type CallOptions struct {
	Tools       []Tool
	Temperature *float64
	MaxTokens   *int
}

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

type FunctionDef struct {
	Name        string
	Description string
	Parameters  map[string]any
}

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

type ToolCall struct {
	ID           string
	Type         string
	FunctionName string
	Arguments    string
}

ToolCall represents a tool call requested by the assistant.

func FromLangChainToolCalls

func FromLangChainToolCalls(tcs []llms.ToolCall) []ToolCall

FromLangChainToolCalls converts langchaingo ToolCalls to our ToolCall type.

type ToolCallResponse

type ToolCallResponse struct {
	ToolCallID string
	Name       string
	Content    string
}

ToolCallResponse represents the result of a tool call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL