From b3dde34ec4d425d544c110f28cb387316893e5f3 Mon Sep 17 00:00:00 2001 From: "tuyang.yhj" Date: Mon, 3 Jul 2023 18:37:25 +0800 Subject: [PATCH] WEB API independent --- pilot/scene/chat_dashboard/prompt.py | 9 +++++--- pilot/server/llmserver.py | 2 +- pilot/server/webserver.py | 31 ++++++++++------------------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pilot/scene/chat_dashboard/prompt.py b/pilot/scene/chat_dashboard/prompt.py index f0b231116..0053e4a51 100644 --- a/pilot/scene/chat_dashboard/prompt.py +++ b/pilot/scene/chat_dashboard/prompt.py @@ -13,13 +13,16 @@ PROMPT_SCENE_DEFINE = """You are a {dialect} data analysis expert, please provid _DEFAULT_TEMPLATE = """ According to the structure definition in the following tables: {table_info} -Provide a professional data analysis with as few dimensions as possible, and the upper limit does not exceed 5 dimensions. +Provide professional data analysis, use as few dimensions as possible, but no less than three, and no more than eight dimensions. Used to support goal: {input} -Use the chart display method in the following range: +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: {supported_chat_type} -give {dialect} data analysis SQL, analysis title, display method and analytical thinking,respond in the following json format: + +Give {dialect} data analysis SQL, analysis title, display method and analytical thinking,respond in the following json format: {response} +Do not use unprovided fields and do not use unprovided data in the where condition of sql. Ensure the response is correct json and can be parsed by Python json.loads """ diff --git a/pilot/server/llmserver.py b/pilot/server/llmserver.py index d87540a8e..e7b5c877f 100644 --- a/pilot/server/llmserver.py +++ b/pilot/server/llmserver.py @@ -168,7 +168,7 @@ async def api_generate_stream(request: Request): @app.post("/generate") -def generate(prompt_request: PromptRequest): +def generate(prompt_request: PromptRequest)->str: params = { "prompt": prompt_request.prompt, "temperature": prompt_request.temperature, diff --git a/pilot/server/webserver.py b/pilot/server/webserver.py index b6c1e2cc3..bc8632579 100644 --- a/pilot/server/webserver.py +++ b/pilot/server/webserver.py @@ -690,9 +690,6 @@ 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") @@ -704,20 +701,14 @@ if __name__ == "__main__": args = parser.parse_args() server_init(args) - if args.new: - import uvicorn - - uvicorn.run(app, host="0.0.0.0", port=5000) - else: - ### Compatibility mode starts the old version server by default - demo = build_webdemo() - demo.queue( - concurrency_count=args.concurrency_count, - status_update_rate=10, - api_open=False, - ).launch( - server_name=args.host, - server_port=args.port, - share=args.share, - max_threads=200, - ) + demo = build_webdemo() + demo.queue( + concurrency_count=args.concurrency_count, + status_update_rate=10, + api_open=False, + ).launch( + server_name=args.host, + server_port=args.port, + share=args.share, + max_threads=200, + )