From 17ada637db772bfc901886b71926de99b69ec4c3 Mon Sep 17 00:00:00 2001 From: H <43509927+guoyuhao2330@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:58:22 +0800 Subject: [PATCH] Fix generate component reset_index and update text2sql template prompt (#2031) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] Documentation Update --------- Co-authored-by: Kevin Hu --- agent/component/generate.py | 2 +- agent/templates/text2sql.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/component/generate.py b/agent/component/generate.py index f7937dbb9..49190babd 100644 --- a/agent/component/generate.py +++ b/agent/component/generate.py @@ -66,7 +66,7 @@ class Generate(ComponentBase): return cpnts def set_cite(self, retrieval_res, answer): - retrieval_res.dropna(subset=["vector", "content_ltks"], inplace=True) + retrieval_res = retrieval_res.dropna(subset=["vector", "content_ltks"]).reset_index(drop=True) if "empty_response" in retrieval_res.columns: retrieval_res["empty_response"].fillna("", inplace=True) answer, idx = retrievaler.insert_citations(answer, [ck["content_ltks"] for _, ck in retrieval_res.iterrows()], diff --git a/agent/templates/text2sql.json b/agent/templates/text2sql.json index 8e592bb5f..ca1787c0f 100644 --- a/agent/templates/text2sql.json +++ b/agent/templates/text2sql.json @@ -51,7 +51,7 @@ } ], "presence_penalty": 0.4, - "prompt": "##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##Respond with only SQL code. Do not answer with any explanations -- just the code.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {ddl_input}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {db_input}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {sql_input}.", + "prompt": "Role: You are an intelligent DB assistant that can help humans generate SQL statements for problems.\n\n##The user provides a question and you provide SQL. You will only respond with SQL code and not with any explanations.\n\n##You may use the following DDL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {ddl_input}.\n\n##You may use the following documentation as a reference for what tables might be available. Use responses to past questions also to guide you: {db_input}.\n\n##You may use the following SQL statements as a reference for what tables might be available. Use responses to past questions also to guide you: {sql_input}.\n\n##Respond with only SQL code. Do not answer with any explanations -- just the code.", "temperature": 0.1, "top_p": 0.3 }