mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-04 10:00:17 +00:00
feat(ChatData): ChatData Strean response
1.ChatData Stream response
This commit is contained in:
parent
bb882a8d73
commit
bf75af520c
@ -23,7 +23,7 @@ class ChatHistoryEntity(Base):
|
|||||||
chat_mode = Column(String(255), nullable=False, comment="Conversation scene mode")
|
chat_mode = Column(String(255), nullable=False, comment="Conversation scene mode")
|
||||||
summary = Column(String(255), nullable=False, comment="Conversation record summary")
|
summary = Column(String(255), nullable=False, comment="Conversation record summary")
|
||||||
user_name = Column(String(255), nullable=True, comment="interlocutor")
|
user_name = Column(String(255), nullable=True, comment="interlocutor")
|
||||||
messages = Column(Text, nullable=True, comment="Conversation details")
|
messages = Column(Text(length=2**31-1), nullable=True, comment="Conversation details")
|
||||||
|
|
||||||
UniqueConstraint("conv_uid", name="uk_conversation")
|
UniqueConstraint("conv_uid", name="uk_conversation")
|
||||||
Index("idx_q_user", "user_name")
|
Index("idx_q_user", "user_name")
|
||||||
|
@ -104,10 +104,11 @@ async def get_editor_sql(con_uid: str, round: int):
|
|||||||
f'history ai json resp:{element["data"]["content"]}'
|
f'history ai json resp:{element["data"]["content"]}'
|
||||||
)
|
)
|
||||||
api_call = ApiCall()
|
api_call = ApiCall()
|
||||||
|
api_call.update_from_context(element["data"]["content"])
|
||||||
result = {}
|
result = {}
|
||||||
result['thoughts'] = element["data"]["content"]
|
result['thoughts'] = element["data"]["content"].replace("\n", " ").replace("\\n", " ")
|
||||||
if api_call.check_last_plugin_call_ready(element["data"]["content"]):
|
if api_call.check_last_plugin_call_ready(element["data"]["content"]):
|
||||||
api_call.update_from_context(element["data"]["content"])
|
|
||||||
if len(api_call.plugin_status_map) > 0:
|
if len(api_call.plugin_status_map) > 0:
|
||||||
first_item = next(iter(api_call.plugin_status_map.items()))[1]
|
first_item = next(iter(api_call.plugin_status_map.items()))[1]
|
||||||
result['sql'] = first_item.args["sql"]
|
result['sql'] = first_item.args["sql"]
|
||||||
|
@ -19,10 +19,8 @@ Table structure information:
|
|||||||
Constraint:
|
Constraint:
|
||||||
1. You can only use the table provided in the table structure information to generate sql. If you cannot generate sql based on the provided table structure, please say: "The table structure information provided is not enough to generate sql query." It is prohibited to fabricate information at will.
|
1. You can only use the table provided in the table structure information to generate sql. If you cannot generate sql based on the provided table structure, please say: "The table structure information provided is not enough to generate sql query." It is prohibited to fabricate information at will.
|
||||||
2. Do not query columns that do not exist. Pay attention to which column is in which table.
|
2. Do not query columns that do not exist. Pay attention to which column is in which table.
|
||||||
3. Replace the corresponding sql into the sql field in the returned result
|
3. Unless the user specifies in the question a specific number of examples he wishes to obtain, always limit the query to a maximum of {top_k} results.
|
||||||
4. Unless the user specifies in the question a specific number of examples he wishes to obtain, always limit the query to a maximum of {top_k} results.
|
4. Please ensure that the output result contains: <api-call><name>response_table</name><args><sql>SQL Query to run</sql></args></api-call>,and replace the generated sql into the parameter sql.Please make sure to respond as following format:
|
||||||
5. Please output the Sql content in the following format to execute the corresponding SQL to display the data:<api-call><name>response_table</name><args><sql>SQL Query to run</sql></args></api-call>
|
|
||||||
Please make sure to respond as following format:
|
|
||||||
thoughts summary to say to user.<api-call><name>response_table</name><args><sql>SQL Query to run</sql></args></api-call>
|
thoughts summary to say to user.<api-call><name>response_table</name><args><sql>SQL Query to run</sql></args></api-call>
|
||||||
|
|
||||||
Question: {input}
|
Question: {input}
|
||||||
@ -36,8 +34,8 @@ _DEFAULT_TEMPLATE_ZH = """
|
|||||||
约束:
|
约束:
|
||||||
1. 只能使用表结构信息中提供的表来生成 sql,如果无法根据提供的表结构中生成 sql ,请说:“提供的表结构信息不足以生成 sql 查询。” 禁止随意捏造信息。
|
1. 只能使用表结构信息中提供的表来生成 sql,如果无法根据提供的表结构中生成 sql ,请说:“提供的表结构信息不足以生成 sql 查询。” 禁止随意捏造信息。
|
||||||
2. 不要查询不存在的列,注意哪一列位于哪张表中。
|
2. 不要查询不存在的列,注意哪一列位于哪张表中。
|
||||||
3.将对应的sql替换到返回结果中的sql字段中
|
3. 请确保输出结果包含<api-call><name>response_table</name><args><sql>要运行的SQL</sql></args></api-call>, 并将对应的sql替换到sql参数中
|
||||||
4.除非用户在问题中指定了他希望获得的具体示例数量,否则始终将查询限制为最多 {top_k} 个结果。
|
4. 除非用户在问题中指定了他希望获得的具体示例数量,否则始终将查询限制为最多 {top_k} 个结果。
|
||||||
|
|
||||||
请务必按照以下格式回复:
|
请务必按照以下格式回复:
|
||||||
对用户说的想法摘要。<api-call><name>response_table</name><args><sql>要运行的 SQL</sql></args></api-call>
|
对用户说的想法摘要。<api-call><name>response_table</name><args><sql>要运行的 SQL</sql></args></api-call>
|
||||||
|
Loading…
Reference in New Issue
Block a user