models

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 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"`
	EmbeddingModel Model `json:"embedding_model"`
}

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"`
	VectorDBConfig   VectorDbConfiguration `json:"vectordb_config"`
	MaxMessages      int                   `json:"max_messages"` // Maximum number of messages in a conversation
	UserColor        string                `json:"term_color"`   // Color for user output in terminal
	Output           bool                  `json:"term_output"`  // Flag to enable/disabled terminal output
	SystemPrompt     string                `json:"system_prompt"`
	EnrichmentPrompt string                `json:"enrichment_prompt"`
	Color            terminal.TermColor
}

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.

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 HttpConfiguration added in v0.1.4

type HttpConfiguration struct {
	MaxInputLength    int `json:"max_input_length"`    // Maximum length of input allowed
	HTTPClientTimeout int `json:"http_client_timeout"` // HTTP client timeout duration
	BufferSize        int `json:"buffer_size"`         // Buffer size for processing data
}

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
}

Message represents an individual message in the chat.

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 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
const (
	Generate StreamType = 1
	Chat     StreamType = 2
)

type VectorDbConfiguration added in v0.1.4

type VectorDbConfiguration struct {
	Type     VectorDbType `json:"type"`
	Endpoint string       `json:"endpoint_url"`
	ApiKey   string       `json:"api_key"`
}

type VectorDbType added in v0.1.4

type VectorDbType string
const (
	SqlVectorDb VectorDbType = "sqlvdb"
	WeaviateDb  VectorDbType = "weaviate"
)

Jump to

Keyboard shortcuts

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