llm

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDecisionPrompt

func BuildDecisionPrompt(agentName, role string, personality map[string]any, state map[string]any) string

BuildDecisionPrompt creates a prompt for the LLM

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles communication with Ollama

func New

func New(cfg Config) (*Client, error)

New creates a new Ollama client

func (*Client) BaseURL added in v0.2.0

func (c *Client) BaseURL() string

BaseURL returns the configured base URL for the LLM provider.

func (*Client) Decide

func (c *Client) Decide(ctx context.Context, prompt string) (*DecisionResponse, error)

Decide prompts the LLM for an action decision

func (*Client) Generate added in v0.2.0

func (c *Client) Generate(ctx context.Context, prompt string) (string, error)

Generate sends a raw prompt to the LLM and returns the response text. Used by the Thought Engine for multi-call decision pipelines. Uses the /api/chat endpoint which handles thinking models (qwen3) properly.

func (*Client) HasPromptManager

func (c *Client) HasPromptManager() bool

HasPromptManager returns whether the prompt manager is initialized

func (*Client) Model added in v0.2.0

func (c *Client) Model() string

Model returns the configured model name.

func (*Client) RenderPrompt

func (c *Client) RenderPrompt(promptType string, role string, ctx *prompts.TemplateContext) (string, error)

RenderPrompt renders a prompt template with the given context. It first tries a role-specific template (e.g., "decision.craftsman") and falls back to the generic template (e.g., "decision") if not found.

func (*Client) SetModel added in v0.2.0

func (c *Client) SetModel(model string)

SetModel changes the LLM model used for subsequent requests.

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context) error

TestConnection tests if Ollama is reachable

type Config

type Config struct {
	BaseURL       string
	Model         string
	Timeout       time.Duration
	PromptsDir    string
	PromptsConfig string
}

Config holds LLM client configuration

type DecisionRequest

type DecisionRequest struct {
	AgentName    string
	Personality  string
	CurrentState string
	Knowledge    string
	Experiences  string
}

DecisionRequest represents a request for an agent decision

type DecisionResponse

type DecisionResponse struct {
	Action     string  `json:"action"`
	Target     string  `json:"target,omitempty"`
	Reasoning  string  `json:"reasoning"`
	Confidence float64 `json:"confidence"`
}

DecisionResponse represents the LLM's decision

Jump to

Keyboard shortcuts

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