models

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultModel = OpenAIMini

Variables

View Source
var ErrEmptyChatHistory = errors.New("Chat history is empty")
View Source
var ErrLastChatCompleted = errors.New("Last chat is already completed with answer")

Functions

func ListModelsSlug

func ListModelsSlug() []string

Types

type BaseModel added in v0.1.0

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

func NewBaseModel added in v0.1.0

func NewBaseModel(client httpclient.IHttpClient, modelProvider IModelProvider) *BaseModel

func (*BaseModel) CompleteChat added in v0.1.0

func (m *BaseModel) CompleteChat(chatHistory *chat.ChatHistory, systemPrompt string) error

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 chat.
	 */
	CompleteChat(chatHistory *chat.ChatHistory, systemPrompt string) error
}

func NewModel

func NewModel(modelType ModelEnum, client httpclient.IHttpClient, config common.Config) IModel

type IModelProvider added in v0.1.0

type IModelProvider interface {
	PreparePayload(chatHistory *chat.ChatHistory, systemPrompt string) (string, error)
	ParseResponse(response []byte) (string, error)
	GetHeaders() map[string]string
	GetUrl() string
}

* * The Provider is only responsible for preparing the payload, * formatting it accordinly to the model's requirements * and parsing the response back to the system.

type ModelEnum

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

func ListModels

func ListModels() []ModelEnum

func (ModelEnum) String

func (m ModelEnum) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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