models

package
v0.3.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OpenAI = "openai" // OpenAI model type
	Ollama = "ollama" // Ollama model type
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AiModels added in v0.1.4

type AiModels struct {
	ChatModel      Model `json:"chat_model"`
	GenerateModel  Model `json:"generate_model"`
	EmbeddingModel Model `json:"embedding_model"`
}

AiModels represents the AI models used by the application.

type ApiEndpointUrls added in v0.1.4

type ApiEndpointUrls struct {
	ApiChatURL       string `json:"api_chat_url"`       // URL for chat API
	ApiGenerateURL   string `json:"api_generate_url"`   // URL for generate API
	ApiEmbedURL      string `json:"api_embed_url"`      // URL for embedding API
	ApiModerationURL string `json:"api_moderation_url"` // URL for moderation API
	ApiModelsURL     string `json:"api_models_url"`     // URL for model API
}

type ApiProvider

type ApiProvider string

ApiProvider indicates the type of response expected.

type Base64Image added in v0.1.1

type Base64Image struct {
	Data string // The base64-encoded data of the image
}

Base64Image represents an image encoded in base64.

func (*Base64Image) GetData added in v0.1.1

func (image *Base64Image) GetData() ([]byte, error)

GetData decodes the base64-encoded data in Data back into a byte slice.

func (Base64Image) MarshalJSON added in v0.1.1

func (b Base64Image) MarshalJSON() ([]byte, error)

MarshalJSON custom marshals Base64Image as a single string.

func (*Base64Image) SetData added in v0.1.1

func (image *Base64Image) SetData(data []byte)

SetData encodes the provided byte slice into a base64 string and assigns it to Data.

type Configuration

type Configuration struct {
	ApiProvider     ApiProvider       `json:"api_provider"` // API provider used
	ApiKey          string            `json:"api_key"`      // API key for authentication
	ApiEndpoints    ApiEndpointUrls   `json:"api_endpoints"`
	AiModels        AiModels          `json:"ai_models"` // Specific AI model to use
	HttpConfig      HttpConfiguration `json:"http_config"`
	MaxMessages     int               `json:"max_messages"` // Maximum number of messages in a conversation
	IncludeStrategy IncludeStrategy   `json:"include_strategy"`
	Terminal        Terminal          `json:"terminal"`
	ActivePersona   Persona           `json:"active_persona"`
	Personas        []Persona         `json:"personas"`
}

Configuration represents the configuration for the application.

func NewConfigFromFile

func NewConfigFromFile(filePath string) (*Configuration, error)

NewConfigFromFile creates a new Configuration instance from a JSON file.

func (*Configuration) GetPersona added in v0.3.1

func (config *Configuration) GetPersona(persona string) Persona

type Document added in v0.1.4

type Document struct {
	ID         string                 `json:"id"`
	ClassName  string                 `json:"classname"`
	Embeddings []float32              `json:"embeddings"`
	Metadata   map[string]interface{} `json:"metadata"`
}

Document represents a stored document with metadata and embeddings.

type EmbeddingRequest

type EmbeddingRequest struct {
	Model          string         `json:"model"`                     // Model to use for embedding
	Input          []string       `json:"input"`                     // Input text or data
	EncodingFormat EncodingFormat `json:"encoding_format,omitempty"` // Encoding format for output
}

EmbeddingsRequest represents the input payload for generating embeddings.

type EmbeddingResponse

type EmbeddingResponse struct {
	Model            string      `json:"model"`             // Model used for embedding
	Embeddings       [][]float32 `json:"embeddings"`        // Generated embeddings
	OriginalResponse any         `json:"original-response"` // the original response of the API call.
}

EmbeddingResponse represents the response payload from generating embeddings.

type EncodingFormat

type EncodingFormat string

EncodingFormat specifies the encoding format for embeddings.

const (
	Float  EncodingFormat = "float"  // Float format
	Base64 EncodingFormat = "base64" // Base64 format
)

type Function added in v0.2.0

type Function struct {
	Type     FunctionType       `json:"type"`
	Function FunctionDefinition `json:"function"`
}

type FunctionDefinition added in v0.2.0

type FunctionDefinition struct {
	FunctionName string            `json:"name"` // The name of the function.
	Description  string            `json:"description"`
	Parameters   FunctionParameter `json:"parameters"`
}

type FunctionParameter added in v0.3.4

type FunctionParameter struct {
	Type       ParameterType        `json:"type"`
	Properties map[string]Parameter `json:"properties"` // The properties of the parameter.
	Required   []string             `json:"required,omitempty"`
}

type FunctionPayload added in v0.2.11

type FunctionPayload struct {
	FunctionName string                 `json:"name"`      // The name of the function.
	Arguments    map[string]interface{} `json:"arguments"` // List of parameters the function takes.
}

type FunctionResponse added in v0.2.0

type FunctionResponse struct {
	Status  FunctionResponseStatus `json:"status"`
	Message string                 `json:"message"`
}

type FunctionResponseStatus added in v0.2.7

type FunctionResponseStatus string
const (
	FunctionResponseStatusSuccess FunctionResponseStatus = "success"
	FunctionResponseStatusError   FunctionResponseStatus = "error"
)

type FunctionType added in v0.3.4

type FunctionType string
const (
	TypeFunction FunctionType = "function"
)

type HttpConfiguration added in v0.1.4

type HttpConfiguration struct {
	HTTPClientTimeout int `json:"http_client_timeout"` // HTTP client timeout duration
}

type IncludeStrategy added in v0.2.0

type IncludeStrategy string
const (
	IncludeBoth      IncludeStrategy = "both"
	IncludeAssistant IncludeStrategy = "assistant"
	IncludeUser      IncludeStrategy = "user"
)

type Message

type Message struct {
	Role            Role           `json:"role"`             // Role of the message (user, assistant, system)
	Content         string         `json:"content"`          // Content of the message
	Images          *[]Base64Image `json:"images,omitempty"` // Images associated with the message
	AlternatePrompt string         `json:"alternate_prompt,omitempty"`
	ToolCalls       []ToolCall     `json:"tool_calls,omitempty"`
}

Message represents an individual message in the chat.

type MessageRequest added in v0.2.0

type MessageRequest struct {
	OriginalMessage       Message    `json:"original_message,omitempty"`
	Message               Message    `json:"message"`
	RetainOriginalMessage bool       `json:"retain_original"`
	Tools                 []Function `json:"tools,omitempty"`
}

type Model added in v0.1.4

type Model struct {
	Model string `json:"model"`
	Name  string `json:"name"`
}

Model represents an AI model with its name and identifier.

type ModerationRequest added in v0.1.1

type ModerationRequest struct {
	Input string `json:"input"`
}

ModerationRequest represents a request to check if a given text contains any content that is considered inappropriate or harmful by OpenAI's standards.

type ModerationResponse added in v0.1.1

type ModerationResponse struct {
	ID               string `json:"id"`
	Model            Model  `json:"model"`
	OriginalResponse any    `json:"results"`
}

ModerationResponse represents the root structure of the moderation response.

type Parameter added in v0.2.0

type Parameter struct {
	Type        string   `json:"type"` // Type of the parameter.
	Description string   `json:"description"`
	Enum        []string `json:"enum,omitempty"` // Optional list of valid values for the parameter.
}

Parameter represents the details of a single parameter.

type ParameterType added in v0.3.4

type ParameterType string
const (
	ObjectType ParameterType = "object"
)

type Persona added in v0.3.1

type Persona struct {
	Name          string   `json:"name"`
	Prompt        Prompt   `json:"prompt"`
	Knowledge     []string `json:"knowledge"`
	AllowedClaims []string `json:"allowed_claims"`
	UseKnowledge  bool     `json:"use_knowledge"`
	UseFunctions  bool     `json:"use_functions"`
}

func (*Persona) AddAllowedClaim added in v0.3.4

func (persona *Persona) AddAllowedClaim(claim string)

func (*Persona) AddKnowledge added in v0.3.1

func (persona *Persona) AddKnowledge(knowledge string)

func (*Persona) RemoveAllowedClaim added in v0.3.4

func (persona *Persona) RemoveAllowedClaim(claim string)

func (*Persona) RemoveKnowledge added in v0.3.1

func (persona *Persona) RemoveKnowledge(knowledge string)

type Prompt added in v0.2.0

type Prompt struct {
	SystemPrompt        string `json:"system_prompt"`
	EnrichmentPrompt    string `json:"enrichment_prompt"`
	SummarizationPrompt string `json:"summarization_prompt"`
}

type Role

type Role string

Role represents a role in a conversation, such as user, assistant, or system.

const (
	System    Role = "system"    // System role
	Developer Role = "developer" // Developer role
	Assistant Role = "assistant" // Assistant role
	User      Role = "user"      // User role
)

type StreamType added in v0.1.4

type StreamType int

the type of streaming endpoint (chat/generate)

const (
	Generate StreamType = 1
	Chat     StreamType = 2
)

type Terminal added in v0.2.0

type Terminal struct {
	UserColor string `json:"term_color"`  // Color for user output in terminal
	Output    bool   `json:"term_output"` // Flag to enable/disabled terminal output
	Debug     bool   `json:"debug"`
	Trace     bool   `json:"trace"`
	Color     terminal.TermColor
}

type Tool added in v0.3.4

type Tool struct {
	Id       string   `json:"tool_id"`
	Endpoint string   `json:"tool_endpoint"`
	ApiKey   string   `json:"tool_apikey"`
	Function Function `json:"tool_definition"` // The function definition.
}

type ToolCall added in v0.3.4

type ToolCall struct {
	Payload FunctionPayload `json:"function"`
}

Jump to

Keyboard shortcuts

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