services

package
v0.0.0-...-4747d10 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

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 Prompts

type Prompts map[string]string

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

implement schema.ChatMessage interface

Jump to

Keyboard shortcuts

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