Feat: load char/agent; agent-chat flow
This commit is contained in:
@@ -17,6 +17,7 @@ type ChatHistory interface {
|
||||
ListChats() ([]models.Chat, error)
|
||||
GetChatByID(id uint32) (*models.Chat, error)
|
||||
GetLastChat() (*models.Chat, error)
|
||||
GetLastChatByAgent(agent string) (*models.Chat, error)
|
||||
UpsertChat(chat *models.Chat) (*models.Chat, error)
|
||||
RemoveChat(id uint32) error
|
||||
ChatGetMaxID() (uint32, error)
|
||||
@@ -45,6 +46,13 @@ func (p ProviderSQL) GetLastChat() (*models.Chat, error) {
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
func (p ProviderSQL) GetLastChatByAgent(agent string) (*models.Chat, error) {
|
||||
resp := models.Chat{}
|
||||
query := "SELECT * FROM chats WHERE agent=$1 ORDER BY updated_at DESC LIMIT 1"
|
||||
err := p.db.Get(&resp, query, agent)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
func (p ProviderSQL) UpsertChat(chat *models.Chat) (*models.Chat, error) {
|
||||
// Prepare the SQL statement
|
||||
query := `
|
||||
|
||||
Reference in New Issue
Block a user