models

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultModel = OpenAIMini

Variables

View Source
var ErrEmptyConversation = errors.New("there are no questions to answer")
View Source
var ErrLastQuestionAlreadyAnswered = errors.New("last conversation has already been answered")
View Source
var ErrModelNotFound = errors.New("model not found")

Functions

func ListModels

func ListModels() map[ModelEnum]string

Types

type BaseModel

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

func NewModel

func NewModel(modelSlug string, client IApiClient, config config.Config) (*BaseModel, error)

func (*BaseModel) CanStream

func (m *BaseModel) CanStream() bool

func (*BaseModel) Complete

func (m *BaseModel) Complete(conversation *conversation.Conversation, systemPrompt string) error

func (*BaseModel) CompleteStreamable

func (m *BaseModel) CompleteStreamable(conversation *conversation.Conversation, systemPrompt string) (<-chan StreamResponse, error)

func (*BaseModel) Model

func (m *BaseModel) Model() ModelEnum

type IApiClient

type IApiClient interface {
	Post(url string, body string, headers map[string]string) ([]byte, error)
	PostWithStreaming(url string, body string, headers map[string]string, parser ProviderStreamParser) <-chan StreamResponse
}

type IModel

type IModel interface {
	// Complete chat receives a chat history with the last chat being the one that needs to be completed.
	// It also receives a system prompt that can be used to generate the answer.
	// Once succeded the model will fill out the answer in the last conversation.
	Complete(chatHistory *conversation.Conversation, systemPrompt string) error

	// Returns the model enum
	Model() ModelEnum
}

type ModelEnum

type ModelEnum string
const (
	OpenAIMini   ModelEnum = "gpt-4o-mini"
	OpenAI       ModelEnum = "gpt-4o"
	ClaudeSonnet ModelEnum = "sonnet"
	Maritaca     ModelEnum = "maritaca"
	Groq         ModelEnum = "groq"
	Ollama       ModelEnum = "ollama"
)

func ParseFrom

func ParseFrom(modelSlug string) (ModelEnum, bool)

func (ModelEnum) Slug

func (m ModelEnum) Slug() string

func (ModelEnum) String

func (m ModelEnum) String() string

type ProviderStreamParser

type ProviderStreamParser func(b []byte) (string, error)

type StreamResponse

type StreamResponse struct {
	Data string
	Err  error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳