Versions in this module Expand all Collapse all v0 v0.1.0 Nov 5, 2023 Changes in this version + const ChatMessageRoleAssistant + const ChatMessageRoleFunction + const ChatMessageRoleSystem + const ChatMessageRoleUser + var DefaultDao = NewMemoryDao() + var NotImplementError = errors.New("the method not implement") + type ChatCompletionChoice struct + FinishReason FinishReason + Index int + Message ChatCompletionMessage + type ChatCompletionMessage struct + Content string + FunctionCall *FunctionCall + Name string + Role string + type ChatCompletionRequest struct + FrequencyPenalty float32 + FunctionCall any + Functions []FunctionDefinition + LogitBias map[string]int + MaxTokens int + Messages []ChatCompletionMessage + Model string + N int + PresencePenalty float32 + Stop []string + Stream bool + Temperature float32 + TopP float32 + User string + func (r *ChatCompletionRequest) FromPrompt(model, prompt string) + func (r *ChatCompletionRequest) ToPrompt() string + func (r *ChatCompletionRequest) ToPromptWithoutRole() string + type ChatCompletionResponse struct + Choices []ChatCompletionChoice + Created int64 + ID string + Model string + Object string + Usage Usage + type ChatCompletionStreamChoice struct + ContentFilterResults ContentFilterResults + Delta ChatCompletionStreamChoiceDelta + FinishReason FinishReason + Index int + type ChatCompletionStreamChoiceDelta struct + Content string + FunctionCall *FunctionCall + Role string + type ChatCompletionStreamResponse struct + Choices []ChatCompletionStreamChoice + Created int64 + ID string + Model string + Object string + PromptAnnotations []PromptAnnotation + func (r *ChatCompletionStreamResponse) ToChatCompletionResponse() ChatCompletionResponse + type ContentFilterResults struct + Hate Hate + SelfHarm SelfHarm + Sexual Sexual + Violence Violence + type Conversation struct + CreatedAt time.Time + Deleted bool + ExtraInfo string + Id string + Model string + Name string + Summary string + UpdatedAt time.Time + UserId string + type Dao interface + DeleteConversation func(ctx context.Context, id string) error + DeleteMessage func(ctx context.Context, id string) error + GetConversation func(ctx context.Context, id string) (Conversation, error) + GetConversationLastMessage func(ctx context.Context, id string) (Message, error) + GetMessage func(ctx context.Context, id string) (Message, error) + ListConversations func(ctx context.Context) ([]Conversation, error) + ListMessages func(ctx context.Context, conversationId string) ([]Message, error) + SaveConversation func(ctx context.Context, conversation Conversation) (Conversation, error) + SaveMessage func(ctx context.Context, message Message) (Message, error) + type FinishReason string + const FinishReasonContentFilter + const FinishReasonFunctionCall + const FinishReasonLength + const FinishReasonNull + const FinishReasonStop + func (r FinishReason) MarshalJSON() ([]byte, error) + type FunctionCall struct + Arguments string + Name string + type FunctionDefine = FunctionDefinition + type FunctionDefinition struct + Description string + Name string + Parameters any + type Hate struct + Filtered bool + Severity string + type LLM struct + func New(dao Dao, c client) *LLM + func (l *LLM) CreateConversation(ctx context.Context, name string) (Conversation, error) + func (l *LLM) CreateMessage(ctx context.Context, conversationId string, req ChatCompletionRequest) (Message, error) + func (l *LLM) CreateMessageStream(ctx context.Context, conversationId string, req ChatCompletionRequest, ...) + func (l *LLM) DeleteConversation(ctx context.Context, id string) error + func (l *LLM) DeleteMessage(ctx context.Context, id string) error + func (l *LLM) GetConversation(ctx context.Context, id string) (Conversation, error) + func (l *LLM) GetMessage(ctx context.Context, id string) (Message, error) + func (l *LLM) ListConversations(ctx context.Context) ([]Conversation, error) + func (l *LLM) ListMessages(ctx context.Context, conversationId string) ([]Message, error) + type MemoryDao struct + func NewMemoryDao() *MemoryDao + func (d *MemoryDao) DeleteConversation(ctx context.Context, id string) error + func (d *MemoryDao) DeleteMessage(ctx context.Context, id string) error + func (d *MemoryDao) GetConversation(ctx context.Context, id string) (Conversation, error) + func (d *MemoryDao) GetConversationLastMessage(ctx context.Context, id string) (Message, error) + func (d *MemoryDao) GetMessage(ctx context.Context, id string) (Message, error) + func (d *MemoryDao) ListConversations(ctx context.Context) ([]Conversation, error) + func (d *MemoryDao) ListMessages(ctx context.Context, conversationId string) ([]Message, error) + func (d *MemoryDao) SaveConversation(ctx context.Context, conversation Conversation) (Conversation, error) + func (d *MemoryDao) SaveMessage(ctx context.Context, message Message) (Message, error) + type Message struct + CompletionToken int + ConversationId string + CreatedAt time.Time + Deleted bool + Description string + Id string + Model string + PromptToken int + RawResponse []byte + Request ChatCompletionRequest + Response ChatCompletionResponse + UpdatedAt time.Time + UserId string + type PromptAnnotation struct + ContentFilterResults ContentFilterResults + PromptIndex int + type SelfHarm struct + Filtered bool + Severity string + type Sexual struct + Filtered bool + Severity string + type Usage struct + CompletionTokens int + PromptTokens int + TotalTokens int + type Violence struct + Filtered bool + Severity string