H Kevin Hu commited on
Commit
2cbcd9d
·
1 Parent(s): 4f06073

Fix generate component reset_index and update text2sql template prompt (#2031)

Browse files

### 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 <[email protected]>

agent/component/generate.py CHANGED
@@ -66,7 +66,7 @@ class Generate(ComponentBase):
66
  return cpnts
67
 
68
  def set_cite(self, retrieval_res, answer):
69
- retrieval_res.dropna(subset=["vector", "content_ltks"], inplace=True)
70
  if "empty_response" in retrieval_res.columns:
71
  retrieval_res["empty_response"].fillna("", inplace=True)
72
  answer, idx = retrievaler.insert_citations(answer, [ck["content_ltks"] for _, ck in retrieval_res.iterrows()],
 
66
  return cpnts
67
 
68
  def set_cite(self, retrieval_res, answer):
69
+ retrieval_res = retrieval_res.dropna(subset=["vector", "content_ltks"]).reset_index(drop=True)
70
  if "empty_response" in retrieval_res.columns:
71
  retrieval_res["empty_response"].fillna("", inplace=True)
72
  answer, idx = retrievaler.insert_citations(answer, [ck["content_ltks"] for _, ck in retrieval_res.iterrows()],
agent/templates/text2sql.json CHANGED
@@ -51,7 +51,7 @@
51
  }
52
  ],
53
  "presence_penalty": 0.4,
54
- "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}.",
55
  "temperature": 0.1,
56
  "top_p": 0.3
57
  }
 
51
  }
52
  ],
53
  "presence_penalty": 0.4,
54
+ "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.",
55
  "temperature": 0.1,
56
  "top_p": 0.3
57
  }