From 35bdf71912dc06b3d0eaf7daf05b8200ab8ac82f Mon Sep 17 00:00:00 2001 From: "tuyang.yhj" Date: Thu, 29 Jun 2023 19:30:14 +0800 Subject: [PATCH 1/3] WEB API independent --- pilot/scene/chat_db/professional_qa/prompt.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pilot/scene/chat_db/professional_qa/prompt.py b/pilot/scene/chat_db/professional_qa/prompt.py index ff360cb65..342e76c76 100644 --- a/pilot/scene/chat_db/professional_qa/prompt.py +++ b/pilot/scene/chat_db/professional_qa/prompt.py @@ -8,7 +8,7 @@ from pilot.common.schema import SeparatorStyle CFG = Config() -PROMPT_SCENE_DEFINE = """A chat between a curious user and an artificial intelligence assistant, who very familiar with database related knowledge. """ +PROMPT_SCENE_DEFINE = """You are an assistant that answers user specialized database questions. """ # PROMPT_SUFFIX = """Only use the following tables generate sql if have any table info: # {table_info} @@ -27,21 +27,24 @@ PROMPT_SCENE_DEFINE = """A chat between a curious user and an artificial intelli # """ _DEFAULT_TEMPLATE_EN = """ -You are a database expert. you will be given metadata information about a database or table, and then provide a brief summary and answer to the question. For example, question: "How many tables are there in database 'db_gpt'?" , answer: "There are 5 tables in database 'db_gpt', which are 'book', 'book_category', 'borrower', 'borrowing', and 'category'. -Based on the database metadata information below, provide users with professional and concise answers to their questions. If the answer cannot be obtained from the provided content, please say: "The information provided in the knowledge base is not sufficient to answer this question." It is forbidden to make up information randomly. -database metadata information: +Provide professional answers to requests and questions. If you can't get an answer from what you've provided, say: "Insufficient information in the knowledge base is available to answer this question." Feel free to fudge information. +Use the following tables generate sql if have any table info: {table_info} -question: + +user question: {input} +think step by step. """ _DEFAULT_TEMPLATE_ZH = """ -你是一位数据库专家。你将获得有关数据库或表的元数据信息,然后提供简要的总结和回答。例如,问题:“数据库 'db_gpt' 中有多少个表?” 答案:“数据库 'db_gpt' 中有 5 个表,分别是 'book'、'book_category'、'borrower'、'borrowing' 和 'category'。” -根据以下数据库元数据信息,为用户提供专业简洁的答案。如果无法从提供的内容中获取答案,请说:“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。 -数据库元数据信息: +根据要求和问题,提供专业的答案。如果无法从提供的内容中获取答案,请说:“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。 + +使用一下表结构信息: {table_info} + 问题: {input} +一步步思考 """ _DEFAULT_TEMPLATE = ( From 865822d1de821e2a64fdbacb76609ccf219fefd5 Mon Sep 17 00:00:00 2001 From: "tuyang.yhj" Date: Thu, 29 Jun 2023 20:41:05 +0800 Subject: [PATCH 2/3] WEB API independent --- datacenter/next.config.js | 5 ++++- datacenter/package.json | 4 +++- datacenter/utils/request.ts | 2 +- pilot/mock_datas/chat_history.db | Bin 12288 -> 0 bytes pilot/mock_datas/chat_history.db.wal | 0 pilot/openapi/api_v1/api_v1.py | 11 +++++++---- pilot/server/dbgpt_server.py | 1 - pilot/server/static/test.html | 2 +- 8 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 pilot/mock_datas/chat_history.db delete mode 100644 pilot/mock_datas/chat_history.db.wal diff --git a/datacenter/next.config.js b/datacenter/next.config.js index ca4a6f7d0..8376cdd5b 100644 --- a/datacenter/next.config.js +++ b/datacenter/next.config.js @@ -2,7 +2,10 @@ const nextConfig = { experimental: { esmExternals: 'loose' - } + }, + images: { + unoptimized: true + }, } module.exports = nextConfig diff --git a/datacenter/package.json b/datacenter/package.json index c17a0586b..038b415ab 100644 --- a/datacenter/package.json +++ b/datacenter/package.json @@ -6,7 +6,9 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "export": "next export", + "compile": "next build && next export" }, "dependencies": { "@ant-design/pro-components": "^2.6.2", diff --git a/datacenter/utils/request.ts b/datacenter/utils/request.ts index 65022c9bd..448d3454b 100644 --- a/datacenter/utils/request.ts +++ b/datacenter/utils/request.ts @@ -2,7 +2,7 @@ import { message } from 'antd'; import axios from 'axios'; import { isPlainObject } from 'lodash'; -axios.defaults.baseURL = 'http://30.183.154.8:5000'; +axios.defaults.baseURL = 'http://localhost:5000'; axios.defaults.timeout = 10000; diff --git a/pilot/mock_datas/chat_history.db b/pilot/mock_datas/chat_history.db deleted file mode 100644 index 929805035e1c69ca980b5e0750d0d4b7cc3c7f3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI#p$&jA5Cu?3V1#;hU<7bD5+-0_W+1i903=|FLtgUE{JYfjURCRDU-L1iaT%t* zdaAjjdwW5E009C72oNAZfB*pk1PH_zXj8ev`Kj{MM1TMR0t5&UAV7cs0RjXFL=^D< ZkN9ftOn?9Z0t5&UAV7cs0Rja630#2eCE)-7 diff --git a/pilot/mock_datas/chat_history.db.wal b/pilot/mock_datas/chat_history.db.wal deleted file mode 100644 index e69de29bb..000000000 diff --git a/pilot/openapi/api_v1/api_v1.py b/pilot/openapi/api_v1/api_v1.py index 17d9b88fe..267deda52 100644 --- a/pilot/openapi/api_v1/api_v1.py +++ b/pilot/openapi/api_v1/api_v1.py @@ -2,13 +2,13 @@ import uuid import json import asyncio import time +import os from fastapi import APIRouter, Request, Body, status, HTTPException, Response, BackgroundTasks -from fastapi.responses import JSONResponse -from fastapi.responses import StreamingResponse +from fastapi.responses import JSONResponse, HTMLResponse +from fastapi.responses import StreamingResponse, FileResponse from fastapi.encoders import jsonable_encoder from fastapi.exceptions import RequestValidationError -from fastapi.responses import JSONResponse from sse_starlette.sse import EventSourceResponse from typing import List @@ -34,7 +34,7 @@ knowledge_service = KnowledgeService() model_semaphore = None global_counter = 0 - +static_file_path = os.path.join(os.getcwd(), "server/static") async def validation_exception_handler(request: Request, exc: RequestValidationError): message = "" @@ -82,6 +82,9 @@ def knowledge_list(): params.update({space.name: space.name}) return params +@router.get("/") +async def read_main(): + return FileResponse(f"{static_file_path}/test.html") @router.get("/v1/chat/dialogue/list", response_model=Result[ConversationVo]) diff --git a/pilot/server/dbgpt_server.py b/pilot/server/dbgpt_server.py index 6c22105cd..b69ca3ab3 100644 --- a/pilot/server/dbgpt_server.py +++ b/pilot/server/dbgpt_server.py @@ -55,7 +55,6 @@ app.add_middleware( ) app.mount("/static", StaticFiles(directory=static_file_path), name="static") -app.add_route("/test", "static/test.html") app.include_router(api_v1) app.add_exception_handler(RequestValidationError, validation_exception_handler) diff --git a/pilot/server/static/test.html b/pilot/server/static/test.html index 709180f11..456fb14c5 100644 --- a/pilot/server/static/test.html +++ b/pilot/server/static/test.html @@ -6,7 +6,7 @@ -
+
Hello World! I'm DB-GPT!