Documentation ¶
Index ¶
- type ChatIdType
- type ChatService
- func (c *ChatService) AddMessage(chatId ChatIdType, message schema.ChatMessage) error
- func (c *ChatService) AssertChatIdExists(chatId ChatIdType) error
- func (c *ChatService) ClearAllMessages() error
- func (c *ChatService) GetMessages(chatId ChatIdType) ([]schema.ChatMessage, error)
- func (c *ChatService) GetSerialzableMessages(chatId ChatIdType) ([]SerializableMessage, error)
- func (c *ChatService) PromptExists(promptName string) bool
- func (c *ChatService) Respond(chatId ChatIdType) (*schema.AIChatMessage, error)
- func (c *ChatService) RespondCallback(chatId ChatIdType, callback func(ctx context.Context, chunk []byte) error) error
- func (c *ChatService) StartChat(promptName string) (ChatIdType, error)
- type Prompts
- type SerializableMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatIdType ¶
type ChatIdType string
type ChatService ¶
type ChatService struct {
// contains filtered or unexported fields
}
func NewChat ¶
func NewChat(modelName string, modelTemp float64, maxLen int, promptPath, redisAddress, ollamaAddress string, log *slog.Logger) (ChatService, error)
initalizes ollama & redis
func (*ChatService) AddMessage ¶
func (c *ChatService) AddMessage(chatId ChatIdType, message schema.ChatMessage) error
adds a message to the Redis instance
func (*ChatService) AssertChatIdExists ¶
func (c *ChatService) AssertChatIdExists(chatId ChatIdType) error
returns nil if chatId exists. Otherwise, returns an error
func (*ChatService) ClearAllMessages ¶
func (c *ChatService) ClearAllMessages() error
wipes redis instance
func (*ChatService) GetMessages ¶
func (c *ChatService) GetMessages(chatId ChatIdType) ([]schema.ChatMessage, error)
gets the official message format from the redis instance
func (*ChatService) GetSerialzableMessages ¶
func (c *ChatService) GetSerialzableMessages(chatId ChatIdType) ([]SerializableMessage, error)
gets our serializable message format from the redis instance
func (*ChatService) PromptExists ¶
func (c *ChatService) PromptExists(promptName string) bool
func (*ChatService) Respond ¶
func (c *ChatService) Respond(chatId ChatIdType) (*schema.AIChatMessage, error)
func (*ChatService) RespondCallback ¶
func (c *ChatService) RespondCallback(chatId ChatIdType, callback func(ctx context.Context, chunk []byte) error) error
func (*ChatService) StartChat ¶
func (c *ChatService) StartChat(promptName string) (ChatIdType, error)
type SerializableMessage ¶
type SerializableMessage struct { Content string `json:"content"` Type schema.ChatMessageType `json:"type"` }
func (SerializableMessage) GetContent ¶
func (sm SerializableMessage) GetContent() string
implement schema.ChatMessage interface
func (SerializableMessage) GetType ¶
func (sm SerializableMessage) GetType() schema.ChatMessageType
implement schema.ChatMessage interface
Click to show internal directories.
Click to hide internal directories.