From ecadf8e287204c9f05d9dfe63b88b47f8d446068 Mon Sep 17 00:00:00 2001
From: Richard Shiue <71320345+richardshiue@users.noreply.github.com>
Date: Thu, 19 Dec 2024 00:12:53 +0800
Subject: [PATCH] chore: find question message from reply message (#1085)
* chore: find question message from answer message id
* chore: sqlx
* test: fix tests
* test: fix test
* chore: apply code suggestions to 2 files
---
...8c14137dd09b11be73442a7f46b2f938b8445.json | 53 +++++++++++++
libs/client-api/src/http_chat.rs | 22 ++++++
libs/database/src/chat/chat_ops.rs | 37 +++++++++
src/api/chat.rs | 23 +++++-
src/biz/chat/ops.rs | 14 +++-
tests/ai_test/chat_test.rs | 76 +++++++++++++++++--
6 files changed, 216 insertions(+), 9 deletions(-)
create mode 100644 .sqlx/query-794c4ced16801b3e98a62eb44c18c14137dd09b11be73442a7f46b2f938b8445.json
diff --git a/.sqlx/query-794c4ced16801b3e98a62eb44c18c14137dd09b11be73442a7f46b2f938b8445.json b/.sqlx/query-794c4ced16801b3e98a62eb44c18c14137dd09b11be73442a7f46b2f938b8445.json
new file mode 100644
index 00000000..1148f8cd
--- /dev/null
+++ b/.sqlx/query-794c4ced16801b3e98a62eb44c18c14137dd09b11be73442a7f46b2f938b8445.json
@@ -0,0 +1,53 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT message_id, content, created_at, author, meta_data, reply_message_id\n FROM af_chat_messages\n WHERE chat_id = $1\n AND reply_message_id = $2\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "message_id",
+ "type_info": "Int8"
+ },
+ {
+ "ordinal": 1,
+ "name": "content",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "created_at",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 3,
+ "name": "author",
+ "type_info": "Jsonb"
+ },
+ {
+ "ordinal": 4,
+ "name": "meta_data",
+ "type_info": "Jsonb"
+ },
+ {
+ "ordinal": 5,
+ "name": "reply_message_id",
+ "type_info": "Int8"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ false,
+ false,
+ true
+ ]
+ },
+ "hash": "794c4ced16801b3e98a62eb44c18c14137dd09b11be73442a7f46b2f938b8445"
+}
diff --git a/libs/client-api/src/http_chat.rs b/libs/client-api/src/http_chat.rs
index 36f015a8..dc540121 100644
--- a/libs/client-api/src/http_chat.rs
+++ b/libs/client-api/src/http_chat.rs
@@ -262,6 +262,28 @@ impl Client {
.into_data()
}
+ pub async fn get_question_message_from_answer_id(
+ &self,
+ workspace_id: &str,
+ chat_id: &str,
+ answer_message_id: i64,
+ ) -> Result