llmservice

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversationDTO

type ConversationDTO struct {
	dtoutils.BaseModel
	UserId    string `json:"user_id"  db:"user_id"`
	Name      string `json:"name,omitempty"  db:"name"`
	Model     string `json:"model,omitempty" db:"model"`
	Summary   string `json:"summary,omitempty" db:"summary"`
	ExtraInfo string `json:"extra_info,omitempty" db:"extra_info"`
}

func (*ConversationDTO) FromLLMConversation

func (c *ConversationDTO) FromLLMConversation(conversation llm.Conversation)

func (ConversationDTO) TableName

func (c ConversationDTO) TableName() string

func (ConversationDTO) ToLLMConversation

func (c ConversationDTO) ToLLMConversation() llm.Conversation

type Dao

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

func NewDao

func NewDao(tx *daos.Dao) *Dao

func (*Dao) DeleteConversation

func (d *Dao) DeleteConversation(ctx context.Context, id string) error

func (*Dao) DeleteMessage

func (d *Dao) DeleteMessage(ctx context.Context, id string) error

func (*Dao) GetConversation

func (d *Dao) GetConversation(ctx context.Context, id string) (llm.Conversation, error)

func (*Dao) GetConversationLastMessage

func (d *Dao) GetConversationLastMessage(ctx context.Context, id string) (llm.Message, error)

func (*Dao) GetMessage

func (d *Dao) GetMessage(ctx context.Context, id string) (llm.Message, error)

func (*Dao) ListConversations

func (d *Dao) ListConversations(ctx context.Context) ([]llm.Conversation, error)

func (*Dao) ListMessages

func (d *Dao) ListMessages(ctx context.Context, conversationId string) ([]llm.Message, error)

func (*Dao) SaveConversation

func (d *Dao) SaveConversation(ctx context.Context, conversation llm.Conversation) (llm.Conversation, error)

func (*Dao) SaveMessage

func (d *Dao) SaveMessage(ctx context.Context, message llm.Message) (llm.Message, error)

type MessageDTO

type MessageDTO struct {
	dtoutils.BaseModel
	UserId          string `json:"user_id"  db:"user_id"`
	ConversationId  string `json:"conversation_id"  db:"conversation_id"`
	Model           string `json:"model,omitempty" db:"model"`
	PromptToken     string `json:"prompt_token,omitempty" db:"prompt_token"`
	CompletionToken string `json:"completion_token,omitempty" db:"completion_token"`
	Description     string `json:"description,omitempty" db:"description"`
	Request         []byte `json:"request,omitempty" db:"request"`
	Response        []byte `json:"response,omitempty" db:"response"`
	RawResponse     []byte `json:"raw_response,omitempty" db:"raw_response"`
}

func (*MessageDTO) FromLLMMessage

func (m *MessageDTO) FromLLMMessage(message llm.Message)

func (MessageDTO) TableName

func (m MessageDTO) TableName() string

func (MessageDTO) ToLLMMessage

func (m MessageDTO) ToLLMMessage() llm.Message

type Service

type Service interface {
	ListModels() []string
	CreateChatCompletion(ctx context.Context, req llm.ChatCompletionRequest) (llm.ChatCompletionResponse, error)
	CreateChatCompletionStream(ctx context.Context, req llm.ChatCompletionRequest, respChan chan llm.ChatCompletionStreamResponse, errChan chan error)

	CreateConversation(ctx context.Context, name string) (llm.Conversation, error)
	ListConversations(ctx context.Context) ([]llm.Conversation, error)
	GetConversation(ctx context.Context, id string) (llm.Conversation, error)
	DeleteConversation(ctx context.Context, id string) error

	CreateMessageStream(ctx context.Context, conversationId string, req llm.ChatCompletionRequest, respChan chan llm.ChatCompletionStreamResponse, errChan chan error)
	CreateMessage(ctx context.Context, conversationId string, req llm.ChatCompletionRequest) (llm.Message, error)
	ListMessages(ctx context.Context, conversationId string) ([]llm.Message, error)
	GetMessage(ctx context.Context, id string) (llm.Message, error)
	DeleteMessage(ctx context.Context, id string) error
}

func New

func New(model string, dao llm.Dao) Service

Jump to

Keyboard shortcuts

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