diff --git a/api/chat_session_service.go b/api/chat_session_service.go index 2438a883..f6794f14 100644 --- a/api/chat_session_service.go +++ b/api/chat_session_service.go @@ -88,7 +88,7 @@ func (s *ChatSessionService) GetSimpleChatSessionsByUserID(ctx context.Context, TopP: float64(session.TopP), MaxTokens: session.MaxTokens, Debug: session.Debug, - Model: session.Model, + Model: session.Model, } }) return simple_sessions, nil diff --git a/api/models.go b/api/models.go index 724989a6..7610c989 100644 --- a/api/models.go +++ b/api/models.go @@ -47,7 +47,7 @@ type SimpleChatSession struct { TopP float64 `json:"topP"` MaxTokens int32 `json:"maxTokens"` Debug bool `json:"debug"` - Model string `json:"model"` + Model string `json:"model"` } type ChatMessageResponse struct { diff --git a/api/sqlc/queries/chat_message.sql b/api/sqlc/queries/chat_message.sql index 7a34716d..97d14075 100644 --- a/api/sqlc/queries/chat_message.sql +++ b/api/sqlc/queries/chat_message.sql @@ -68,15 +68,15 @@ WHERE cm.id = $1 AND (cs.user_id = $2 OR au.is_superuser) and cs.active = true; -- name: GetLatestMessagesBySessionUUID :many SELECT * FROM chat_message -Where chat_session_uuid in +Where chat_message.id in ( - SELECT chat_session_uuid + SELECT chat_message.id FROM chat_message WHERE chat_message.chat_session_uuid = $1 ORDER BY created_at DESC - LIMIT $2 + LIMIT $2 ) -ORDER BY created_at ; +ORDER BY created_at; -- name: GetFirstMessageBySessionUUID :one diff --git a/api/sqlc_queries/chat_message.sql.go b/api/sqlc_queries/chat_message.sql.go index 5d309bea..c8835e7d 100644 --- a/api/sqlc_queries/chat_message.sql.go +++ b/api/sqlc_queries/chat_message.sql.go @@ -413,13 +413,13 @@ func (q *Queries) GetLastNChatMessages(ctx context.Context, arg GetLastNChatMess const getLatestMessagesBySessionUUID = `-- name: GetLatestMessagesBySessionUUID :many SELECT id, uuid, chat_session_uuid, role, content, score, user_id, created_at, updated_at, created_by, updated_by, raw FROM chat_message -Where chat_session_uuid in +Where chat_message.id in ( - SELECT chat_session_uuid + SELECT chat_message.id FROM chat_message WHERE chat_message.chat_session_uuid = $1 ORDER BY created_at DESC - LIMIT $2 + LIMIT $2 ) ORDER BY created_at `