brain

package
v0.3.1-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEchoServer added in v0.2.0

func NewEchoServer(t *testing.T, expectedModel, expectedToken string) *httptest.Server

NewEchoServer creates a test server that echoes back the user message

func NewErrorServer added in v0.2.0

func NewErrorServer(t *testing.T) *httptest.Server

NewErrorServer creates a test server that returns an error response

Types

type Brain

type Brain interface {
	Ask(question string) (string, error)
}

Brain represents an interface for asking questions and receiving answers.

func New

func New(provider, token, system string, playbook ...string) (Brain, error)

New creates a new instance of Brain based on the provided provider and optional playbook strings.

func NewDeepSeek

func NewDeepSeek(apiKey, _ string) Brain

NewDeepSeek creates a new deepSeek instance with the provided API key.

func NewMetricBrain added in v0.2.0

func NewMetricBrain(brain Brain, s *stats.Stats) Brain

NewMetricBrain creates a new MetricBrain instance wrapping the given Brain and using the provided stats for writing statistics.

func NewMock

func NewMock(playbooks ...string) Brain

NewMock creates a new instance of MockBrain with the provided playbooks. If no playbooks are provided, a default echo playbook will be used.

func NewOpenAI added in v0.2.0

func NewOpenAI(apiKey, system string) Brain

NewOpenAI creates a new OpenAI instance

type EchoPlaybook added in v0.2.0

type EchoPlaybook struct{}

EchoPlaybook represents a playbook that echoes back the question asked.

func NewEchoPlaybook added in v0.2.0

func NewEchoPlaybook() *EchoPlaybook

NewEchoPlaybook creates a new instance of EchoPlaybook.

func (*EchoPlaybook) Ask added in v0.2.0

func (e *EchoPlaybook) Ask(question string) string

Ask echoes back the provided question.

type MetricBrain added in v0.2.0

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

MetricBrain is a wrapper around a Brain with added functionality to track metrics such as the duration of each question asked.

func (*MetricBrain) Ask added in v0.2.0

func (b *MetricBrain) Ask(question string) (string, error)

Ask sends a question to the underlying Brain and tracks the time taken to process the question.

type Playbook added in v0.2.0

type Playbook interface {
	Ask(question string) string
}

Playbook defines the interface for a playbook that can ask questions and return answers. It is used in tests mostly.

type YAMLPlaybook added in v0.2.0

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

YAMLPlaybook represents a playbook loaded from a YAML file.

func NewYAMLPlaybook added in v0.2.0

func NewYAMLPlaybook(filePath string) (*YAMLPlaybook, error)

NewYAMLPlaybook loads a YAML playbook from the specified file path and returns a YAMLPlaybook instance.

func (*YAMLPlaybook) Ask added in v0.2.0

func (p *YAMLPlaybook) Ask(question string) string

Ask retrieves the answer to a given question from the playbook. If the question is not found, it returns a default "not found" message.

Jump to

Keyboard shortcuts

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