mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-19 00:37:34 +00:00
Merge remote-tracking branch 'origin/dev_ty_06_end' into llm_framework
This commit is contained in:
commit
d2e82d575e
44
pilot/connections/rdbms/py_study/study_enum.py
Normal file
44
pilot/connections/rdbms/py_study/study_enum.py
Normal file
@ -0,0 +1,44 @@
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
class Test(Enum):
|
||||
XXX = ("x", "1", True)
|
||||
YYY =("Y", "2", False)
|
||||
ZZZ = ("Z", "3")
|
||||
def __init__(self, code, v, flag= False):
|
||||
self.code = code
|
||||
self.v = v
|
||||
self.flag = flag
|
||||
|
||||
class Scene:
|
||||
def __init__(self, code, name, describe, param_types:List=[], is_inner: bool = False):
|
||||
self.code = code
|
||||
self.name = name
|
||||
self.describe = describe
|
||||
self.param_types = param_types
|
||||
self.is_inner = is_inner
|
||||
|
||||
|
||||
class ChatScene(Enum):
|
||||
|
||||
ChatWithDbExecute = Scene("chat_with_db_execute", "Chat Data", "Dialogue with your private data through natural language.", ["DB Select"])
|
||||
ChatWithDbQA = Scene("chat_with_db_qa", "Chat Meta Data", "Have a Professional Conversation with Metadata.", ["DB Select"])
|
||||
ChatExecution = Scene("chat_execution", "Chat Plugin", "Use tools through dialogue to accomplish your goals.", ["Plugin Select"])
|
||||
ChatDefaultKnowledge = Scene("chat_default_knowledge", "Chat Default Knowledge", "Dialogue through natural language and private documents and knowledge bases.")
|
||||
ChatNewKnowledge = Scene("chat_new_knowledge", "Chat New Knowledge", "Dialogue through natural language and private documents and knowledge bases.", ["Knowledge Select"])
|
||||
ChatUrlKnowledge = Scene("chat_url_knowledge", "Chat URL", "Dialogue through natural language and private documents and knowledge bases.", ["Url Input"])
|
||||
InnerChatDBSummary = Scene("inner_chat_db_summary", "DB Summary", "Db Summary.", True)
|
||||
|
||||
ChatNormal = Scene("chat_normal", "Chat Normal", "Native LLM large model AI dialogue.")
|
||||
ChatDashboard = Scene("chat_dashboard", "Chat Dashboard", "Provide you with professional analysis reports through natural language.", ["DB Select"])
|
||||
ChatKnowledge = Scene("chat_knowledge", "Chat Knowledge", "Dialogue through natural language and private documents and knowledge bases.", ["Knowledge Space Select"])
|
||||
|
||||
def scene_value(self):
|
||||
return self.value.code;
|
||||
|
||||
def scene_name(self):
|
||||
return self._value_.name;
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(ChatScene.ChatWithDbExecute.scene_value())
|
||||
# print(ChatScene.ChatWithDbExecute.value.describe)
|
@ -36,8 +36,9 @@ class DuckdbHistoryMemory(BaseChatHistoryMemory):
|
||||
if not result:
|
||||
# 如果表不存在,则创建新表
|
||||
self.connect.execute(
|
||||
"CREATE TABLE chat_history (conv_uid VARCHAR(100) PRIMARY KEY, chat_mode VARCHAR(50), summary VARCHAR(255), user_name VARCHAR(100), messages TEXT)"
|
||||
"CREATE TABLE chat_history (id integer primary key, conv_uid VARCHAR(100) UNIQUE, chat_mode VARCHAR(50), summary VARCHAR(255), user_name VARCHAR(100), messages TEXT)"
|
||||
)
|
||||
self.connect.execute("CREATE SEQUENCE seq_id START 1;")
|
||||
|
||||
def __get_messages_by_conv_uid(self, conv_uid: str):
|
||||
cursor = self.connect.cursor()
|
||||
@ -59,7 +60,7 @@ class DuckdbHistoryMemory(BaseChatHistoryMemory):
|
||||
try:
|
||||
cursor = self.connect.cursor()
|
||||
cursor.execute(
|
||||
"INSERT INTO chat_history(conv_uid, chat_mode summary, user_name, messages)VALUES(?,?,?,?,?)",
|
||||
"INSERT INTO chat_history(id, conv_uid, chat_mode summary, user_name, messages)VALUES(nextval('seq_id'),?,?,?,?,?)",
|
||||
[self.chat_seesion_id, chat_mode, summary, user_name, ""],
|
||||
)
|
||||
cursor.commit()
|
||||
@ -81,7 +82,7 @@ class DuckdbHistoryMemory(BaseChatHistoryMemory):
|
||||
)
|
||||
else:
|
||||
cursor.execute(
|
||||
"INSERT INTO chat_history(conv_uid, chat_mode, summary, user_name, messages)VALUES(?,?,?,?,?)",
|
||||
"INSERT INTO chat_history(id, conv_uid, chat_mode, summary, user_name, messages)VALUES(nextval('seq_id'),?,?,?,?,?)",
|
||||
[
|
||||
self.chat_seesion_id,
|
||||
once_message.chat_mode,
|
||||
@ -115,10 +116,10 @@ class DuckdbHistoryMemory(BaseChatHistoryMemory):
|
||||
cursor = duckdb.connect(duckdb_path).cursor()
|
||||
if user_name:
|
||||
cursor.execute(
|
||||
"SELECT * FROM chat_history where user_name=? limit 20", [user_name]
|
||||
"SELECT * FROM chat_history where user_name=? order by id desc limit 20", [user_name]
|
||||
)
|
||||
else:
|
||||
cursor.execute("SELECT * FROM chat_history limit 20")
|
||||
cursor.execute("SELECT * FROM chat_history order by id desc limit 20")
|
||||
# 获取查询结果字段名
|
||||
fields = [field[0] for field in cursor.description]
|
||||
data = []
|
||||
|
@ -66,7 +66,7 @@ def __get_conv_user_message(conversations: dict):
|
||||
|
||||
def __new_conversation(chat_mode, user_id) -> ConversationVo:
|
||||
unique_id = uuid.uuid1()
|
||||
history_mem = DuckdbHistoryMemory(str(unique_id))
|
||||
# history_mem = DuckdbHistoryMemory(str(unique_id))
|
||||
return ConversationVo(conv_uid=str(unique_id), chat_mode=chat_mode)
|
||||
|
||||
|
||||
@ -102,12 +102,7 @@ async def read_main():
|
||||
|
||||
|
||||
@router.get("/v1/chat/dialogue/list", response_model=Result[ConversationVo])
|
||||
async def dialogue_list(response: Response, user_id: str = None):
|
||||
# 设置CORS头部信息
|
||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
response.headers["Access-Control-Allow-Methods"] = "GET"
|
||||
response.headers["Access-Control-Request-Headers"] = "content-type"
|
||||
|
||||
async def dialogue_list( user_id: str = None):
|
||||
dialogues: List = []
|
||||
datas = DuckdbHistoryMemory.conv_list(user_id)
|
||||
|
||||
@ -132,43 +127,41 @@ async def dialogue_scenes():
|
||||
new_modes: List[ChatScene] = [
|
||||
ChatScene.ChatWithDbExecute,
|
||||
ChatScene.ChatWithDbQA,
|
||||
ChatScene.ChatDashboard,
|
||||
ChatScene.ChatKnowledge,
|
||||
ChatScene.ChatDashboard,
|
||||
ChatScene.ChatExecution,
|
||||
]
|
||||
for scene in new_modes:
|
||||
if not scene.value in [
|
||||
ChatScene.ChatNormal.value,
|
||||
ChatScene.InnerChatDBSummary.value,
|
||||
]:
|
||||
scene_vo = ChatSceneVo(
|
||||
chat_scene=scene.value,
|
||||
scene_name=scene.name,
|
||||
param_title="Selection Param",
|
||||
)
|
||||
scene_vos.append(scene_vo)
|
||||
|
||||
scene_vo = ChatSceneVo(
|
||||
chat_scene=scene.value(),
|
||||
scene_name=scene.scene_name(),
|
||||
scene_describe= scene.describe(),
|
||||
param_title=",".join(scene.param_types()),
|
||||
)
|
||||
scene_vos.append(scene_vo)
|
||||
return Result.succ(scene_vos)
|
||||
|
||||
|
||||
@router.post("/v1/chat/dialogue/new", response_model=Result[ConversationVo])
|
||||
async def dialogue_new(
|
||||
chat_mode: str = ChatScene.ChatNormal.value, user_id: str = None
|
||||
chat_mode: str = ChatScene.ChatNormal.value(), user_id: str = None
|
||||
):
|
||||
conv_vo = __new_conversation(chat_mode, user_id)
|
||||
return Result.succ(conv_vo)
|
||||
|
||||
|
||||
@router.post("/v1/chat/mode/params/list", response_model=Result[dict])
|
||||
async def params_list(chat_mode: str = ChatScene.ChatNormal.value):
|
||||
if ChatScene.ChatWithDbQA.value == chat_mode:
|
||||
async def params_list(chat_mode: str = ChatScene.ChatNormal.value()):
|
||||
if ChatScene.ChatWithDbQA.value() == chat_mode:
|
||||
return Result.succ(get_db_list())
|
||||
elif ChatScene.ChatWithDbExecute.value == chat_mode:
|
||||
elif ChatScene.ChatWithDbExecute.value() == chat_mode:
|
||||
return Result.succ(get_db_list())
|
||||
elif ChatScene.ChatDashboard.value == chat_mode:
|
||||
elif ChatScene.ChatDashboard.value() == chat_mode:
|
||||
return Result.succ(get_db_list())
|
||||
elif ChatScene.ChatExecution.value == chat_mode:
|
||||
elif ChatScene.ChatExecution.value() == chat_mode:
|
||||
return Result.succ(plugins_select_info())
|
||||
elif ChatScene.ChatKnowledge.value == chat_mode:
|
||||
elif ChatScene.ChatKnowledge.value() == chat_mode:
|
||||
return Result.succ(knowledge_list())
|
||||
else:
|
||||
return Result.succ(None)
|
||||
@ -201,7 +194,7 @@ async def dialogue_history_messages(con_uid: str):
|
||||
async def chat_completions(dialogue: ConversationVo = Body()):
|
||||
print(f"chat_completions:{dialogue.chat_mode},{dialogue.select_param}")
|
||||
if not dialogue.chat_mode:
|
||||
dialogue.chat_mode = ChatScene.ChatNormal.value
|
||||
dialogue.chat_mode = ChatScene.ChatNormal.value()
|
||||
if not dialogue.conv_uid:
|
||||
conv_vo = __new_conversation(dialogue.chat_mode, dialogue.user_name)
|
||||
dialogue.conv_uid = conv_vo.conv_uid
|
||||
@ -222,17 +215,17 @@ async def chat_completions(dialogue: ConversationVo = Body()):
|
||||
"user_input": dialogue.user_input,
|
||||
}
|
||||
|
||||
if ChatScene.ChatWithDbQA.value == dialogue.chat_mode:
|
||||
if ChatScene.ChatWithDbQA.value() == dialogue.chat_mode:
|
||||
chat_param.update({"db_name": dialogue.select_param})
|
||||
elif ChatScene.ChatWithDbExecute.value == dialogue.chat_mode:
|
||||
elif ChatScene.ChatWithDbExecute.value() == dialogue.chat_mode:
|
||||
chat_param.update({"db_name": dialogue.select_param})
|
||||
elif ChatScene.ChatDashboard.value == dialogue.chat_mode:
|
||||
elif ChatScene.ChatDashboard.value() == dialogue.chat_mode:
|
||||
chat_param.update({"db_name": dialogue.select_param})
|
||||
## DEFAULT
|
||||
chat_param.update({"report_name": "sales_report"})
|
||||
elif ChatScene.ChatExecution.value == dialogue.chat_mode:
|
||||
elif ChatScene.ChatExecution.value() == dialogue.chat_mode:
|
||||
chat_param.update({"plugin_selector": dialogue.select_param})
|
||||
elif ChatScene.ChatKnowledge.value == dialogue.chat_mode:
|
||||
elif ChatScene.ChatKnowledge.value() == dialogue.chat_mode:
|
||||
chat_param.update({"knowledge_space": dialogue.select_param})
|
||||
|
||||
chat: BaseChat = CHAT_FACTORY.get_implementation(dialogue.chat_mode, **chat_param)
|
||||
|
@ -26,7 +26,8 @@ class Result(Generic[T], BaseModel):
|
||||
class ChatSceneVo(BaseModel):
|
||||
chat_scene: str = Field(..., description="chat_scene")
|
||||
scene_name: str = Field(..., description="chat_scene name show for user")
|
||||
param_title: str = Field(..., description="chat_scene required parameter title")
|
||||
scene_describe: str = Field("", description="chat_scene describe ")
|
||||
param_title: str = Field("", description="chat_scene required parameter title")
|
||||
|
||||
|
||||
class ConversationVo(BaseModel):
|
||||
|
@ -1,28 +1,52 @@
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
|
||||
class Scene:
|
||||
def __init__(self, code, describe, is_inner):
|
||||
def __init__(self, code, name, describe, param_types: List = [], is_inner: bool = False):
|
||||
self.code = code
|
||||
self.name = name
|
||||
self.describe = describe
|
||||
self.param_types = param_types
|
||||
self.is_inner = is_inner
|
||||
|
||||
|
||||
class ChatScene(Enum):
|
||||
ChatWithDbExecute = "chat_with_db_execute"
|
||||
ChatWithDbQA = "chat_with_db_qa"
|
||||
ChatExecution = "chat_execution"
|
||||
ChatDefaultKnowledge = "chat_default_knowledge"
|
||||
ChatNewKnowledge = "chat_new_knowledge"
|
||||
ChatUrlKnowledge = "chat_url_knowledge"
|
||||
InnerChatDBSummary = "inner_chat_db_summary"
|
||||
ChatWithDbExecute = Scene("chat_with_db_execute", "Chat Data",
|
||||
"Dialogue with your private data through natural language.", ["DB Select"])
|
||||
ChatWithDbQA = Scene("chat_with_db_qa", "Chat Meta Data", "Have a Professional Conversation with Metadata.",
|
||||
["DB Select"])
|
||||
ChatExecution = Scene("chat_execution", "Plugin", "Use tools through dialogue to accomplish your goals.",
|
||||
["Plugin Select"])
|
||||
ChatDefaultKnowledge = Scene("chat_default_knowledge", "Chat Default Knowledge",
|
||||
"Dialogue through natural language and private documents and knowledge bases.")
|
||||
ChatNewKnowledge = Scene("chat_new_knowledge", "Chat New Knowledge",
|
||||
"Dialogue through natural language and private documents and knowledge bases.",
|
||||
["Knowledge Select"])
|
||||
ChatUrlKnowledge = Scene("chat_url_knowledge", "Chat URL",
|
||||
"Dialogue through natural language and private documents and knowledge bases.",
|
||||
["Url Input"])
|
||||
InnerChatDBSummary = Scene("inner_chat_db_summary", "DB Summary", "Db Summary.", True)
|
||||
|
||||
ChatNormal = "chat_normal"
|
||||
ChatDashboard = "chat_dashboard"
|
||||
ChatKnowledge = "chat_knowledge"
|
||||
# ChatDb = "chat_db"
|
||||
# ChatData= "chat_data"
|
||||
ChatNormal = Scene("chat_normal", "Chat Normal", "Native LLM large model AI dialogue.")
|
||||
ChatDashboard = Scene("chat_dashboard", "Dashboard",
|
||||
"Provide you with professional analysis reports through natural language.", ["DB Select"])
|
||||
ChatKnowledge = Scene("chat_knowledge", "Chat Knowledge",
|
||||
"Dialogue through natural language and private documents and knowledge bases.",
|
||||
["Knowledge Space Select"])
|
||||
|
||||
@staticmethod
|
||||
def is_valid_mode(mode):
|
||||
return any(mode == item.value for item in ChatScene)
|
||||
return any(mode == item.value() for item in ChatScene)
|
||||
|
||||
def value(self):
|
||||
return self._value_.code;
|
||||
|
||||
def scene_name(self):
|
||||
return self._value_.name;
|
||||
|
||||
def describe(self):
|
||||
return self._value_.describe;
|
||||
|
||||
def param_types(self):
|
||||
return self._value_.param_types
|
||||
|
@ -73,10 +73,10 @@ class BaseChat(ABC):
|
||||
|
||||
### load prompt template
|
||||
self.prompt_template: PromptTemplate = CFG.prompt_templates[
|
||||
self.chat_mode.value
|
||||
self.chat_mode.value()
|
||||
]
|
||||
self.history_message: List[OnceConversation] = self.memory.messages()
|
||||
self.current_message: OnceConversation = OnceConversation(chat_mode.value)
|
||||
self.current_message: OnceConversation = OnceConversation(chat_mode.value())
|
||||
self.current_tokens_used: int = 0
|
||||
|
||||
class Config:
|
||||
|
@ -23,7 +23,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatDashboard(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatDashboard.value
|
||||
chat_scene: str = ChatScene.ChatDashboard.value()
|
||||
report_name: str
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -17,7 +17,7 @@ Provide professional data analysis, use as few dimensions as possible, but no le
|
||||
Used to support goal: {input}
|
||||
|
||||
Pay attention to the length of the output content of the analysis result, do not exceed 4000tokens
|
||||
According to the characteristics of the analyzed data, choose the best one from the charts provided below to display,chart types:
|
||||
According to the characteristics of the analyzed data, choose the best one from the charts provided below to display, use different types of charts as much as possible,chart types:
|
||||
{supported_chat_type}
|
||||
|
||||
Give {dialect} data analysis SQL, analysis title, display method and analytical thinking,respond in the following json format:
|
||||
@ -40,7 +40,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = False
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatDashboard.value,
|
||||
template_scene=ChatScene.ChatDashboard.value(),
|
||||
input_variables=["input", "table_info", "dialect", "supported_chat_type"],
|
||||
response_format=json.dumps(RESPONSE_FORMAT, indent=4),
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "sale_report",
|
||||
"introduce": "",
|
||||
"layout": "TODO",
|
||||
"supported_chart_type":["HeatMap","sheet", "LineChart", "PieChart", "BarChart"],
|
||||
"supported_chart_type":["HeatMap","sheet", "LineChart", "PieChart", "BarChart", "Scatterplot", "IndicatorValue", "Table"],
|
||||
"key_metrics":[],
|
||||
"trends": []
|
||||
}
|
@ -17,7 +17,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatWithDbAutoExecute(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatWithDbExecute.value
|
||||
chat_scene: str = ChatScene.ChatWithDbExecute.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -35,15 +35,15 @@ class DbChatOutputParser(BaseOutputParser):
|
||||
if len(data) <= 1:
|
||||
data.insert(0, ["result"])
|
||||
df = pd.DataFrame(data[1:], columns=data[0])
|
||||
if CFG.NEW_SERVER_MODE:
|
||||
html = df.to_html(index=False, escape=False, sparsify=False)
|
||||
html = "".join(html.split())
|
||||
else:
|
||||
if not CFG.NEW_SERVER_MODE:
|
||||
table_style = """<style>
|
||||
table{border-collapse:collapse;width:100%;height:80%;margin:0 auto;float:center;border: 1px solid #007bff; background-color:#333; color:#fff}th,td{border:1px solid #ddd;padding:3px;text-align:center}th{background-color:#C9C3C7;color: #fff;font-weight: bold;}tr:nth-child(even){background-color:#444}tr:hover{background-color:#444}
|
||||
</style>"""
|
||||
html_table = df.to_html(index=False, escape=False)
|
||||
html = f"<html><head>{table_style}</head><body>{html_table}</body></html>"
|
||||
else:
|
||||
html = df.to_html(index=False, escape=False, sparsify=False)
|
||||
html = "".join(html.split())
|
||||
|
||||
view_text = f"##### {str(speak)}" + "\n" + html.replace("\n", " ")
|
||||
return view_text
|
||||
|
@ -37,7 +37,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = False
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatWithDbExecute.value,
|
||||
template_scene=ChatScene.ChatWithDbExecute.value(),
|
||||
input_variables=["input", "table_info", "dialect", "top_k", "response"],
|
||||
response_format=json.dumps(RESPONSE_FORMAT_SIMPLE, indent=4),
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -15,7 +15,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatWithDbQA(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatWithDbQA.value
|
||||
chat_scene: str = ChatScene.ChatWithDbQA.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -59,7 +59,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatWithDbQA.value,
|
||||
template_scene=ChatScene.ChatWithDbQA.value(),
|
||||
input_variables=["input", "table_info"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -16,7 +16,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatWithPlugin(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatExecution.value
|
||||
chat_scene: str = ChatScene.ChatExecution.value()
|
||||
plugins_prompt_generator: PluginPromptGenerator
|
||||
select_plugin: str = None
|
||||
|
||||
|
@ -40,7 +40,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_STREAM_OUT = False
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatExecution.value,
|
||||
template_scene=ChatScene.ChatExecution.value(),
|
||||
input_variables=["input", "constraints", "commands_infos", "response"],
|
||||
response_format=json.dumps(RESPONSE_FORMAT, indent=4),
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -23,7 +23,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatNewKnowledge(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatNewKnowledge.value
|
||||
chat_scene: str = ChatScene.ChatNewKnowledge.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -38,7 +38,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatNewKnowledge.value,
|
||||
template_scene=ChatScene.ChatNewKnowledge.value(),
|
||||
input_variables=["context", "question"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -25,7 +25,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatDefaultKnowledge(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatDefaultKnowledge.value
|
||||
chat_scene: str = ChatScene.ChatDefaultKnowledge.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -39,7 +39,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatDefaultKnowledge.value,
|
||||
template_scene=ChatScene.ChatDefaultKnowledge.value(),
|
||||
input_variables=["context", "question"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -8,7 +8,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class InnerChatDBSummary(BaseChat):
|
||||
chat_scene: str = ChatScene.InnerChatDBSummary.value
|
||||
chat_scene: str = ChatScene.InnerChatDBSummary.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -38,7 +38,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = False
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.InnerChatDBSummary.value,
|
||||
template_scene=ChatScene.InnerChatDBSummary.value(),
|
||||
input_variables=["db_profile_summary", "db_input", "response"],
|
||||
response_format=json.dumps(RESPONSE_FORMAT, indent=4),
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -24,7 +24,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatUrlKnowledge(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatUrlKnowledge.value
|
||||
chat_scene: str = ChatScene.ChatUrlKnowledge.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -38,7 +38,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatUrlKnowledge.value,
|
||||
template_scene=ChatScene.ChatUrlKnowledge.value(),
|
||||
input_variables=["context", "question"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -61,4 +61,4 @@ class ChatKnowledge(BaseChat):
|
||||
|
||||
@property
|
||||
def chat_type(self) -> str:
|
||||
return ChatScene.ChatKnowledge.value
|
||||
return ChatScene.ChatKnowledge.value()
|
||||
|
@ -39,7 +39,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatKnowledge.value,
|
||||
template_scene=ChatScene.ChatKnowledge.value(),
|
||||
input_variables=["context", "question"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -14,7 +14,7 @@ CFG = Config()
|
||||
|
||||
|
||||
class ChatNormal(BaseChat):
|
||||
chat_scene: str = ChatScene.ChatNormal.value
|
||||
chat_scene: str = ChatScene.ChatNormal.value()
|
||||
|
||||
"""Number of results to return from the query"""
|
||||
|
||||
|
@ -17,7 +17,7 @@ PROMPT_SEP = SeparatorStyle.SINGLE.value
|
||||
PROMPT_NEED_NEED_STREAM_OUT = True
|
||||
|
||||
prompt = PromptTemplate(
|
||||
template_scene=ChatScene.ChatNormal.value,
|
||||
template_scene=ChatScene.ChatNormal.value(),
|
||||
input_variables=["input"],
|
||||
response_format=None,
|
||||
template_define=PROMPT_SCENE_DEFINE,
|
||||
|
@ -91,15 +91,19 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--port", type=int, default=5000)
|
||||
parser.add_argument("--concurrency-count", type=int, default=10)
|
||||
parser.add_argument("--share", default=False, action="store_true")
|
||||
parser.add_argument("-light", "--light", default=False,action="store_true", help="enable light mode")
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
# init server config
|
||||
args = parser.parse_args()
|
||||
|
||||
from pilot.server.llmserver import worker
|
||||
worker.start_check()
|
||||
server_init(args)
|
||||
CFG.NEW_SERVER_MODE = True
|
||||
import uvicorn
|
||||
|
||||
if not args.light:
|
||||
print("Model Unified Deployment Mode!")
|
||||
from pilot.server.llmserver import worker
|
||||
worker.start_check()
|
||||
CFG.NEW_SERVER_MODE = True
|
||||
|
||||
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=args.port)
|
||||
|
@ -690,6 +690,9 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
"--model_list_mode", type=str, default="once", choices=["once", "reload"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"-new", "--new", action="store_true", help="enable new http mode"
|
||||
)
|
||||
|
||||
# old version server config
|
||||
parser.add_argument("--host", type=str, default="0.0.0.0")
|
||||
|
Loading…
Reference in New Issue
Block a user