Documentation
¶
Index ¶
- func NewEchoServer(t *testing.T, expectedModel, expectedToken string) *httptest.Server
- func NewErrorServer(t *testing.T) *httptest.Server
- type Brain
- func New(provider, url, token, model, system string, playbook ...string) (Brain, error)
- func NewCustom(token, url, model, system string) (Brain, error)
- func NewDeepSeek(apiKey, _ string) Brain
- func NewMetricBrain(brain Brain, s *stats.Stats) Brain
- func NewMock(playbooks ...string) Brain
- func NewOllama(address, model, token, system string) Brain
- func NewOpenAI(token, url, model, system string) (Brain, error)
- func NewOpenAIDefault(token, system string) (Brain, error)
- type EchoPlaybook
- type MetricBrain
- type Playbook
- type YAMLPlaybook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEchoServer ¶ added in v0.2.0
NewEchoServer creates a test server that echoes back the user message
Types ¶
type Brain ¶
Brain represents an interface for asking questions and receiving answers.
func New ¶
New creates a new instance of Brain based on the provided provider and optional playbook strings.
func NewDeepSeek ¶
NewDeepSeek creates a new deepSeek instance with the provided API key.
func NewMetricBrain ¶ added in v0.2.0
NewMetricBrain creates a new MetricBrain instance wrapping the given Brain and using the provided stats for writing statistics.
func NewMock ¶
NewMock creates a new instance of MockBrain with the provided playbooks. If no playbooks are provided, a default echo playbook will be used.
func NewOllama ¶ added in v0.3.4
NewOllama creates a new instance of the Brain implementation using the Ollama API.
Parameters:
- address (string): The base URL of the Ollama API.
- model (string): The AI model to use for chat interactions.
- token (string): The authentication token for accessing the API.
- system (string): The initial system prompt or context for the AI model.
Returns:
- Brain: An instance of the Brain interface configured to use the Ollama API.
func NewOpenAIDefault ¶ added in v0.3.5
NewOpenAIDefault creates a new OpenAI instance with default settings
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.
type Playbook ¶ added in v0.2.0
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.