chat

package
v0.0.0-...-4ad5de9 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatApp

type ChatApp struct {
	Client       *http.Client
	ChatService  *ChatService
	Scanner      *bufio.Scanner
	ApiKey       string
	CurrentModel string
	Models       []string
	CurrentTopic ChatTopic
	Topics       []*ChatTopic
}

func NewChatApp

func NewChatApp(client *http.Client, chatService *ChatService, scanner *bufio.Scanner, apiKey string, models []string) (*ChatApp, error)

type ChatResponse

type ChatResponse struct {
	ID        string     `json:"id"`
	Model     string     `json:"model"`
	Time      string     `json:"time"`
	UserQuery Message    `json:"user_query"`
	Object    string     `json:"object"`
	Topic     *ChatTopic `json:"topic"`
}

ChatResponse to be received and stored

type ChatService

type ChatService struct {
	ChatApp *ChatApp
	// contains filtered or unexported fields
}

func NewChatService

func NewChatService(cs PPLXChatStore) *ChatService

func (*ChatService) ClearEntries

func (cs *ChatService) ClearEntries() error

func (*ChatService) ClearEntriesByTopic

func (cs *ChatService) ClearEntriesByTopic(name string) error

func (*ChatService) CreateThread

func (cs *ChatService) CreateThread(t *Thread) error

func (*ChatService) CreateTopic

func (cs *ChatService) CreateTopic(t *ChatTopic) error

func (*ChatService) DeleteThread

func (cs *ChatService) DeleteThread(ID uuid.UUID) error

func (*ChatService) DeleteTopic

func (cs *ChatService) DeleteTopic(ID uuid.UUID) error

func (*ChatService) GetChatResponse

func (cs *ChatService) GetChatResponse(ID string) (*ChatResponse, error)

func (*ChatService) GetThread

func (cs *ChatService) GetThread(ID uuid.UUID) (*Thread, error)

func (*ChatService) GetTopic

func (cs *ChatService) GetTopic(ID uuid.UUID) (*ChatTopic, error)

func (*ChatService) ListChatResponses

func (cs *ChatService) ListChatResponses() ([]*ChatResponse, error)

func (*ChatService) ListThreads

func (cs *ChatService) ListThreads() ([]*Thread, error)

func (*ChatService) ListTopics

func (cs *ChatService) ListTopics() ([]*ChatTopic, error)

func (*ChatService) NewChatApp

func (cs *ChatService) NewChatApp(client *http.Client, chatService *ChatService, scanner *bufio.Scanner, apiKey string, models []string) (*ChatApp, error)

func (*ChatService) SaveChatResponse

func (cs *ChatService) SaveChatResponse(cr *ChatResponse) error

func (*ChatService) UpdateThread

func (cs *ChatService) UpdateThread(ID uuid.UUID, t *Thread) error

func (*ChatService) UpdateTopic

func (cs *ChatService) UpdateTopic(ID uuid.UUID, t *ChatTopic) error

type ChatStore

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

func NewChatStore

func NewChatStore(dbPath string) (*ChatStore, error)

func (*ChatStore) ClearEntries

func (cs *ChatStore) ClearEntries() (err error)

func (*ChatStore) Close

func (cs *ChatStore) Close() error

func (*ChatStore) RetrieveEntries

func (cs *ChatStore) RetrieveEntries() ([]Entry, error)

func (*ChatStore) SaveEntry

func (cs *ChatStore) SaveEntry(userInput string, aiResponse Response) error

type ChatTopic

type ChatTopic struct {
	ID          uuid.UUID `'json:"id"`
	Name        string    `'json:"name"`
	Description string    `'json:"description"`
	Threads     []Thread  `'json:"threads"`
}

func NewChatTopic

func NewChatTopic(name, description string) *ChatTopic

type Entry

type Entry struct {
	ID         int       `json:"id" storm:"id,increment"`
	Timestamp  time.Time `json:"timestamp"`
	UserInput  string    `json:"user_input"`
	AIResponse Response  `json:"ai_response"`
}

type Message

type Message struct {
	ID         uuid.UUID
	Model      string
	Primer     Primer
	Temprature float64
	TopP       float64
	FreqPen    float64
	Stream     bool
	Query      string
}

Message is the message to be sent to the chatbot

func NewMessage

func NewMessage(query string, model string) Message

type OResponse

type OResponse struct {
	ID    string `json:"id"`
	Model string `json:"model"`
	Time  string `json:"time"`
	Text  string `json:"text"`
}

type PPLXChatStore

type PPLXChatStore interface {
	CreateThread(t *Thread) error
	GetThread(ID uuid.UUID) (*Thread, error)
	ListThreads() ([]*Thread, error)
	UpdateThread(ID uuid.UUID, t *Thread) error
	DeleteThread(ID uuid.UUID) error

	CreateTopic(t *ChatTopic) error
	GetTopic(ID uuid.UUID) (*ChatTopic, error)
	ListTopics() ([]*ChatTopic, error)
	DeleteTopic(ID uuid.UUID) error
	UpdateTopic(ID uuid.UUID, t *ChatTopic) error

	SaveChatResponse(cr *ChatResponse) error
	GetChatResponse(ID string) (*ChatResponse, error)
	ListChatResponses() ([]*ChatResponse, error)
	ClearEntries() error
	ClearEntriesByTopic(name string) error
}

type Primer

type Primer struct {
	System []map[string]string
	User   []map[string]string
}

type Response

type Response struct {
	ID      string `json:"id"`
	Model   string `json:"model"`
	Created string `json:"created"`
	Object  string `json:"object"`

	Choices []struct {
		Message struct {
			Role    string `json:"role"`
			Content string `json:"content"`
		} `json:"message"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
}

type StromRepo

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

func NewStromRepo

func NewStromRepo(db *storm.DB) *StromRepo

func (*StromRepo) ClearEntries

func (sr *StromRepo) ClearEntries() error

func (*StromRepo) ClearEntriesByTopic

func (sr *StromRepo) ClearEntriesByTopic(name string) error

func (*StromRepo) CreateThread

func (sr *StromRepo) CreateThread(t *Thread) error

func (*StromRepo) CreateTopic

func (sr *StromRepo) CreateTopic(t *ChatTopic) error

func (*StromRepo) DeleteThread

func (sr *StromRepo) DeleteThread(ID uuid.UUID) error

func (*StromRepo) DeleteTopic

func (sr *StromRepo) DeleteTopic(ID uuid.UUID) error

func (*StromRepo) GetChatResponse

func (sr *StromRepo) GetChatResponse(ID string) (*ChatResponse, error)

func (*StromRepo) GetThread

func (sr *StromRepo) GetThread(ID uuid.UUID) (*Thread, error)

func (*StromRepo) GetTopic

func (sr *StromRepo) GetTopic(ID uuid.UUID) (*ChatTopic, error)

func (*StromRepo) ListChatResponses

func (sr *StromRepo) ListChatResponses() ([]*ChatResponse, error)

func (*StromRepo) ListThreads

func (sr *StromRepo) ListThreads() ([]*Thread, error)

func (*StromRepo) ListTopics

func (sr *StromRepo) ListTopics() ([]*ChatTopic, error)

func (*StromRepo) SaveChatResponse

func (sr *StromRepo) SaveChatResponse(cr *ChatResponse) error

func (*StromRepo) UpdateThread

func (sr *StromRepo) UpdateThread(ID uuid.UUID, t *Thread) error

func (*StromRepo) UpdateTopic

func (sr *StromRepo) UpdateTopic(ID uuid.UUID, t *ChatTopic) error

type TEntry

type TEntry struct {
	ID         int       `json:"id" storm:"id,increment"`
	Timestamp  time.Time `json:"timestamp"`
	UserInput  string    `json:"user_input"`
	AIResponse TResponse `json:"ai_response"`
	Topic      Topic     `json:"topic"`
}

type TResponse

type TResponse struct {
	ID      string `json:"id"`
	Model   string `json:"model"`
	Created string `json:"created"`
	Object  string `json:"object"`

	Choices []struct {
		Message struct {
			Role    string `json:"role"`
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
}

type Thread

type Thread struct {
	ID      uuid.UUID
	Created time.Time
	Name    string
	Msgs    []ChatResponse
}

func NewThread

func NewThread(name string) *Thread

type Topic

type Topic struct {
	ID   int    `json:"id" storm:"id,increment"`
	Name string `json:"name"`
}

func NewTopic

func NewTopic(name string) *Topic

type TopicStore

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

func NewTopicStore

func NewTopicStore(dbPath string) (*TopicStore, error)

func (*TopicStore) Close

func (ts *TopicStore) Close() error

func (*TopicStore) RetrieveEntries

func (ts *TopicStore) RetrieveEntries() ([]TEntry, error)

func (*TopicStore) RetrieveEntriesByTopic

func (ts *TopicStore) RetrieveEntriesByTopic(topic string) ([]TEntry, error)

func (*TopicStore) RetrieveTopicByName

func (ts *TopicStore) RetrieveTopicByName(name string) (Topic, error)

func (*TopicStore) RetrieveTopics

func (ts *TopicStore) RetrieveTopics() ([]Topic, error)

func (*TopicStore) SaveEntry

func (ts *TopicStore) SaveEntry(userInput string, aiResponse TResponse, topic Topic) error

func (*TopicStore) SaveTopic

func (ts *TopicStore) SaveTopic(name string) error

Jump to

Keyboard shortcuts

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