From 7bcd7d81bcf38b6990a9925b705aa30d4dbe9c79 Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 5 Feb 2025 16:19:23 -0700 Subject: [PATCH 1/2] make sure the output of fix sql is delimited --- .../analyst_chat_prompts/failed_to_fix_sql_prompts.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs b/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs index 11bb95a2b..308196fe2 100644 --- a/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs +++ b/api/src/utils/prompts/analyst_chat_prompts/failed_to_fix_sql_prompts.rs @@ -8,6 +8,11 @@ You should talk about how you tried to fix the SQL query three times, and that y At the end make sure to apologize to the user +PLEASE OUTPUT THE SQL QUERY IN THE FOLLOWING FORMAT: +```sql + +``` + ### GENERAL GUIDELINES - Keep your response under 50 words - Do not output the failed SQL query in your response From fb75c1f554bee4c7bbd383ef27346e3ce8cbc5ae Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 5 Feb 2025 16:23:24 -0700 Subject: [PATCH 2/2] fix(search): Add organization_id filter to semantic and terms search queries --- .../routes/ws/threads_and_messages/post_thread/post_thread.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/src/routes/ws/threads_and_messages/post_thread/post_thread.rs b/api/src/routes/ws/threads_and_messages/post_thread/post_thread.rs index 5c52c2a77..e41c26d3a 100644 --- a/api/src/routes/ws/threads_and_messages/post_thread/post_thread.rs +++ b/api/src/routes/ws/threads_and_messages/post_thread/post_thread.rs @@ -1227,6 +1227,7 @@ async fn search_for_relevant_terms( terms_search where fts @@ websearch_to_tsquery('{prompt}') + and organization_id = '{organization_id}' order by rank_ix limit least(10, 30) * 2 ), @@ -1236,6 +1237,7 @@ semantic as ( row_number() over (order by embedding <#> '{prompt_embedding}') as rank_ix from terms_search + where organization_id = '{organization_id}' order by rank_ix limit least(10, 30) * 2 )