Documentation
¶
Index ¶
- Constants
- type AiModels
- type ApiEndpointUrls
- type ApiProvider
- type Base64Image
- type Configuration
- type Document
- type EmbeddingRequest
- type EmbeddingResponse
- type EncodingFormat
- type Function
- type FunctionDefinition
- type FunctionParameter
- type FunctionPayload
- type FunctionResponse
- type FunctionResponseStatus
- type FunctionType
- type HttpConfiguration
- type IncludeStrategy
- type Message
- type MessageRequest
- type Model
- type ModerationRequest
- type ModerationResponse
- type Parameter
- type ParameterType
- type Persona
- type Prompt
- type Role
- type StreamType
- type Terminal
- type Tool
- type ToolCall
Constants ¶
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 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 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 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) AddKnowledge ¶ added in v0.3.1
func (*Persona) RemoveAllowedClaim ¶ added in v0.3.4
func (*Persona) RemoveKnowledge ¶ added in v0.3.1
type Role ¶
type Role string
Role represents a role in a conversation, such as user, assistant, or system.
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 ToolCall ¶ added in v0.3.4
type ToolCall struct {
Payload FunctionPayload `json:"function"`
}