llm

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *defaultTool

Types

type Client

type Client interface {
	Prompt(ctx context.Context, opts PrompterOpts) (string, error)
}

type GrokPrompter

type GrokPrompter struct {
	APIKey string
	URL    string
	Model  string
}

GrokPrompter is a prompter for the Grok LLM.

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a message in the conversation. For contextual messages, see:

type MessageRole

type MessageRole = string

MessageRole represents the role of a message.

const (
	// MessageRoleSystem is the role for the system message.
	MessageRoleSystem MessageRole = "system"
	// MessageRoleUser is the role for the user message.
	MessageRoleUser MessageRole = "user"
	// MessageRoleAssistant is the role for the assistant message.
	MessageRoleAssistant MessageRole = "assistant"
	// GrokChatCompletionsURL is the URL for the Grok LLM API.
	GrokChatCompletionsURL = "https://api.x.ai/v1/chat/completions"
	// Grok2LatestModel is the latest model for the Grok LLM.
	Grok2LatestModel = "grok-2-latest"
)

type PrompterOpts

type PrompterOpts struct {
	SystemPrompt   string          // The system prompt for the LLM.
	UserPrompt     string          // The user prompt for the LLM.
	Context        []Message       // The context for the LLM.
	Temperature    float64         // The temperature for the LLM.
	ResponseFormat *ResponseFormat // The response format for the LLM.
	AdditionalOpts map[string]any  // Additional options for the LLM to be implemented by prompters, optionally.
}

PrompterOpts represents the options for the Prompter.

type ResponseFormat

type ResponseFormat struct {
	Type       string        `json:"type"`
	JSONSchema *schemaFormat `json:"json_schema,omitempty"`
}

ResponseFormat represents the response format customization.

Jump to

Keyboard shortcuts

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