prise en charge des outils + weather
This commit is contained in:
1 parent
a36f1231cd
commit
0a6ffab050
14 files changed
+623
-113
No files matched your search
@@ -67,18 +67,43 @@ func (r *TursoChatRepository) DeleteChat(userID string, teamID string, id string
|
||||
)
|
||||
}
|
||||
|
||||
func (r *TursoChatRepository) GetChatMessages(userID string, teamID string, chatID string) ([]*domain.Message, error) {
|
||||
return r.messageTable.Select(
|
||||
orm.WithWhere(
|
||||
"chat_id=$1 and team_id=$2 and team_id in (select team_id from user_teams where user_id=$3)",
|
||||
chatID,
|
||||
teamID,
|
||||
userID,
|
||||
),
|
||||
orm.WithOrder("_date_created asc"),
|
||||
)
|
||||
func (r *TursoChatRepository) GetChatMessages(userID string, teamID string, chatID string, withToolCallResponses bool) ([]*domain.Message, error) {
|
||||
var messages []*domain.Message
|
||||
var err error
|
||||
if !withToolCallResponses {
|
||||
messages, err = r.messageTable.Select(
|
||||
orm.WithWhere(
|
||||
`chat_id=$1
|
||||
and team_id=$2
|
||||
and team_id in (select team_id from user_teams where user_id=$3)
|
||||
and (tool_call_id='' or tool_call_id is null)`,
|
||||
chatID,
|
||||
teamID,
|
||||
userID,
|
||||
),
|
||||
orm.WithOrder("_date_created asc"),
|
||||
)
|
||||
} else {
|
||||
messages, err = r.messageTable.Select(
|
||||
orm.WithWhere(
|
||||
"chat_id=$1 and team_id=$2 and team_id in (select team_id from user_teams where user_id=$3)",
|
||||
chatID,
|
||||
teamID,
|
||||
userID,
|
||||
),
|
||||
orm.WithOrder("_date_created asc"),
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, m := range messages {
|
||||
m.Json2toolCall()
|
||||
}
|
||||
return messages, nil
|
||||
}
|
||||
|
||||
func (r *TursoChatRepository) CreateChatMessage(userID string, message *domain.Message) (*domain.Message, error) {
|
||||
message.ToolCall2Json()
|
||||
return r.messageTable.Insert(message)
|
||||
}
|
||||
Reference in new issue
Block a user