diff --git a/assets/chat_agent/agent_hub_1.png b/assets/chat_agent/agent_hub_1.png new file mode 100644 index 000000000..e2b95bf73 Binary files /dev/null and b/assets/chat_agent/agent_hub_1.png differ diff --git a/assets/chat_agent/agent_hub_2.png b/assets/chat_agent/agent_hub_2.png new file mode 100644 index 000000000..9c7c50b02 Binary files /dev/null and b/assets/chat_agent/agent_hub_2.png differ diff --git a/assets/chat_agent/chat_agent0.png b/assets/chat_agent/chat_agent0.png new file mode 100644 index 000000000..14650a744 Binary files /dev/null and b/assets/chat_agent/chat_agent0.png differ diff --git a/assets/chat_agent/chat_agent1.png b/assets/chat_agent/chat_agent1.png index af3f1c715..bd77b9033 100644 Binary files a/assets/chat_agent/chat_agent1.png and b/assets/chat_agent/chat_agent1.png differ diff --git a/assets/chat_agent/chat_agent2.png b/assets/chat_agent/chat_agent2.png new file mode 100644 index 000000000..220266964 Binary files /dev/null and b/assets/chat_agent/chat_agent2.png differ diff --git a/docker/examples/excel/example.xlsx b/docker/examples/excel/example.xlsx new file mode 100644 index 000000000..f049f345b Binary files /dev/null and b/docker/examples/excel/example.xlsx differ diff --git a/docker/examples/excel/zx.csv b/docker/examples/excel/zx.csv new file mode 100644 index 000000000..9e1d45724 --- /dev/null +++ b/docker/examples/excel/zx.csv @@ -0,0 +1,69 @@ +序号,大项,明细,备注,预算,实际,费用小计,超额,已支出,支出小计,其他 +1,中央空调,内外机,1拖5 140 31600,30600,30600,30600,0,30600,30600, +2,基装,地砖,,106000,32100,107948.4,1948.4,32100,107948.4,1948.4 +3,,地板,,,,,,,, +4,,门,颜色升级,,37450,,,37450,, +5,,橱柜,浴柜、马桶、花洒 自选,,,,,,, +6,,卫生间墙地,,,28149.4,,,28149.4,, +7,,厨房,墙、地(大改小增项)、菜盆去掉自选,,,,,,, +8,,打拆改建,,,10249,,,10249,, +9,其他费用,物业装修管理费(物业),405.58,26936.23,405.58,20836.23,-6100,405.58,20036.23, +10,,建渣清运费(物业),281.65,,281.65,,,281.65,, +11,,打拆清运费(物业),1300,,1300,,,1300,, +,,预交水费,200,,200,,,200,, +,,客卧加墙,1500,,1500,,,1500,, +,,天然气暗改,1800,,1800,,,1800,, +,,天然气明改,719,,719,,,719,, +,,开槽(150),0,,0,,,0,, +,,防水增加,358,,358,,,358,, +,,墙砖背胶(大砖上墙加背胶),208,,208,,,208,, +,,美缝3000,3100,,3100,,,2500,, +,,淋浴隔断(18980439828),3130,,3130,,,3130,, +,,橱柜增加费用,4500,,,,,,, +,,电费,200,,200,,,200,, +,,门锁,844,,844,,,844,, +,,空调机位封窗,1500,,1500,,,1300,, +,,开关灯安装,1000,,,,,,, +,,空调机位门,600,,,,,,, +,,瓷白胶,190,,190,,,190,, +,,瓷白胶人工,300,,300,,,300,, +,,每逢增加(橱柜浴柜),,,,,,,, +,,乳胶漆人工,,,,,,,, +12,,乳胶漆自购,4800,,4800,,,4800,, +13,水电改造,材料,16446,18636,16446,18425,-211,16446,18425, +14,,人工,,,,,,,, +,,开关插座补,531,,320,,,320,, +15,,开关插座,1659,,1659,,,1659,, +16,封窗,,15000,14500,14500,14500,0,4500,14500, +,,,,,,,,8000,, +17,,,,,,,,2000,, +18,基装(自购),马桶*2,9000,8200,8200,20000,,8200,20000, +19,,花洒*2,3000,4000,4000,,,4000,, +20,,浴柜*2,5000,4600,4600,,,4600,, +21,,菜盆,2500,3200,3200,,,3200,, +22,衣柜定做,鞋柜亮面、衣柜肤质、板材克诺斯邦、侧面表层,40*730,33000,5000,31000,,5000,31000, +23,,,,,15000,,,15000,, +,,,,,11000,,,11000,, +24,,,,,,,,,, +25,基础家电,燃气热水器,计划史密斯智能4000,3798,3798,18551,,3798,18841,24期免息 +,,燃气热水器安装,,355,355,,,355,, +26,,洗碗机,计划西门子5999,6999,6999,,,6999,, +27,,冰箱,计划西门子,6000,,,,,, +28,,电视,,8000,,,,,, +,,洗衣机(安装),,290,,,,290,, +,,抽油烟机+灶具(升级),方太型号升级,3900,3900,,,3900,, +29,,洗衣机,计划西门子6500,3499,3499,,,3499,, +30,软装,沙发,15000,71799.8,,10877.8,,,9777.8, +31,,茶几,5000,,,,,,, +32,,电视柜,6000,,,,,,, +33,,餐桌,7000,,,,,,, +34,,床*2,7000,,,,,,, +,,床垫*2,13000,,,,,,, +,,窗帘,10400,,10500,,,9400,, +,,洞灯,399.8,,377.8,,,377.8,, +,,书桌,2000,,,,,,, +35,,灯具,6000,,,,,,, +36,合计,,,354313.03,272738.43,272738.43,-4362.6,,271128.43,-83184.6 +37,,,,,,,,,, +38,双十一,,,,,38551,,,, +,,,,,,,,,, \ No newline at end of file diff --git a/docs/getting_started/application/chatagent/chatagent.md b/docs/getting_started/application/chatagent/chatagent.md index c0d90247d..44b0df15e 100644 --- a/docs/getting_started/application/chatagent/chatagent.md +++ b/docs/getting_started/application/chatagent/chatagent.md @@ -1,25 +1,24 @@ ChatAgent ================================== ChatAgent can automatically select the right tool to answer and solve user problems through LLM. -![ChatAgent](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) +![ChatAgent](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/chat_agent0.png) ### 1.Update Plugins From Git Update the latest plug-in information from the DB-GPT official plug-in repository. -![Update From Github](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) +![Update From Github](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/agent_hub_1.png) ### 2.Install Plugin Install the plugin you want to use from the list of agent hub plugins. -![Install Plugin](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) - +![Update From Github](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/agent_hub_1.png) ### 3.Upload My Local Plugin File If you want to use a private plug-in developed by yourself, you can upload the plug-in first and then use it. -![Upload Private Plugin](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) ### 4.Select installed plug-ins dialog Select an installed plugin to have a conversation. -![Select Plugins](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) +![Select Plugins](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/chat_agent1.png) +![Success Use](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/chat_agent2.png) ### 5.Uninstall My Plugin Uninstall plugins you no longer need. -![Uninstall Plugin](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/) \ No newline at end of file +![Uninstall Plugin](https://github.com/eosphoros-ai/DB-GPT/blob/82d8e4f3bd74bfe7f19b96e51d3483f382227bed/assets/chat_agent/agent_hub_2.png) \ No newline at end of file diff --git a/docs/getting_started/application/chatdb/img.png b/docs/getting_started/application/chatdb/img.png new file mode 100644 index 000000000..b6a3afc5e Binary files /dev/null and b/docs/getting_started/application/chatdb/img.png differ diff --git a/docs/getting_started/faq/deploy/deploy_faq.md b/docs/getting_started/faq/deploy/deploy_faq.md index 1262395fc..c787337ed 100644 --- a/docs/getting_started/faq/deploy/deploy_faq.md +++ b/docs/getting_started/faq/deploy/deploy_faq.md @@ -97,4 +97,10 @@ pip install langchain>=0.0.286 ```commandline pip install --use-pep517 fschat -``` \ No newline at end of file +``` + +##### Q9: alembic.util.exc.CommandError: Target database is not up to date. +delete files in `DB-GPT/pilot/meta_data/alembic/versions/` and reboot. +```commandline +rm -rf DB-GPT/pilot/meta_data/alembic/versions/* +``` diff --git a/docs/getting_started/install/cluster/vms/standalone.md b/docs/getting_started/install/cluster/vms/standalone.md new file mode 100644 index 000000000..6e75e7d05 --- /dev/null +++ b/docs/getting_started/install/cluster/vms/standalone.md @@ -0,0 +1,98 @@ +Standalone Deployment +================================== +(standalone-index)= + +### Install Prepare +```commandline +git clone https://github.com/eosphoros-ai/DB-GPT.git + +cd DB-GPT +``` + +### Create conda environment +```commandline +conda create -n dbgpt_env python=3.10 + +conda activate dbgpt_env +``` + + +### Install Default Requirements +```commandline +# Install Default Requirements +pip install -e ".[default]" +``` + +### Download and Prepare LLM Model and Embedding Model +```{tip} + If you don't have high performance hardware server +``` +you can use openai api, tongyi api , bard api, etc. +```commandline +mkdir models && cd models + +# download embedding model, eg: text2vec-large-chinese +git clone https://huggingface.co/GanymedeNil/text2vec-large-chinese + +``` + +set proxy api in .env +```commandline +#set LLM_MODEL TYPE +LLM_MODEL=proxyllm +#set your Proxy Api key and Proxy Server url +PROXY_API_KEY={your-openai-sk} +PROXY_SERVER_URL=https://api.openai.com/v1/chat/completions +``` +```{tip} +If you have high performance hardware server +``` + +```commandline +mkdir models && cd models + +# # download embedding model, eg: vicuna-13b-v1.5 or +git clone https://huggingface.co/lmsys/vicuna-13b-v1.5 + +# download embedding model, eg: text2vec-large-chinese +git clone https://huggingface.co/GanymedeNil/text2vec-large-chinese + +popd +``` +### Start all services with a single command. +```commandline +LLM_MODEL=vicuna-13b-v1.5 +dbgpt start webserver --port 6006 +``` +By default, the "dbgpt start webserver" command will start the Webserver, Model Controller, and Model Worker in a single Python process. Here, we specify the service to be started on port 6006. + +### View and validate the model service in the command line, you can use the following commands +##### 1.list the started model services and deployed Model Workers, you can use the following command +```commandline +dbgpt model list +``` +output is: +```commandline ++-----------------+------------+------------+------+---------+---------+-----------------+----------------------------+ +| Model Name | Model Type | Host | Port | Healthy | Enabled | Prompt Template | Last Heartbeat | ++-----------------+------------+------------+------+---------+---------+-----------------+----------------------------+ +| vicuna-13b-v1.5 | llm | 172.17.0.9 | 6006 | True | True | | 2023-10-16T19:49:59.201313 | +| WorkerManager | service | 172.17.0.9 | 6006 | True | True | | 2023-10-16T19:49:59.246756 | ++-----------------+------------+------------+------+---------+---------+-----------------+----------------------------+ +``` +The WorkerManager is the management process for Model Workers + +##### validate the deployed model in the command line, you can use the following command +```commandline +dbgpt model chat --model_name vicuna-13b-v1.5 +``` +Then an interactive page will be launched where you can have a conversation with the deployed LLM in the terminal. +```commandline +Chatbot started with model vicuna-13b-v1.5. Type 'exit' to leave the chat. + + +You: Hello +Bot: Hello! How can I assist you today? + +You: +``` \ No newline at end of file diff --git a/docs/locales/zh_CN/LC_MESSAGES/getting_started/application/chatagent/chatagent.po b/docs/locales/zh_CN/LC_MESSAGES/getting_started/application/chatagent/chatagent.po new file mode 100644 index 000000000..8e43a26e4 --- /dev/null +++ b/docs/locales/zh_CN/LC_MESSAGES/getting_started/application/chatagent/chatagent.po @@ -0,0 +1,123 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, csunny +# This file is distributed under the same license as the DB-GPT package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: DB-GPT 👏👏 0.3.9\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-17 17:24+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../getting_started/application/chatagent/chatagent.md:1 +#: ../../getting_started/application/chatagent/chatagent.md:3 +#: 17aae18073594c7498c8b2434d50b218 77f0177e55e144a89e3bcf735b0d52de +msgid "ChatAgent" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:3 +#: 41b42808938245dc946960571c09026a +msgid "" +"ChatAgent can automatically select the right tool to answer and solve " +"user problems through LLM. ![ChatAgent](https://github.com/eosphoros-ai" +"/DB-GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:6 +#: bb76bb44442647a091d008c9e1427e4a +msgid "1.Update Plugins From Git" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:7 +#: a7f188c3de7e4b85b2d3079128b535b2 +msgid "" +"Update the latest plug-in information from the DB-GPT official plug-in " +"repository. ![Update From Github](https://github.com/eosphoros-ai/DB-" +"GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:7 +#: 612cb75edb2f48a087fc99e6d0890b80 +msgid "Update From Github" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:10 +#: 1ad3f7680837410cb8018fff5787366f +msgid "2.Install Plugin" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:11 +#: b32e9318a8e347339b6c4cad4b966880 +msgid "" +"Install the plugin you want to use from the list of agent hub plugins. " +"![Install Plugin](https://github.com/eosphoros-ai/DB-" +"GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:11 +#: bee96f7936564bc6be98655bfc6aae0d +msgid "Install Plugin" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:15 +#: 20d562b9ed004336bb6df8d163554924 +msgid "3.Upload My Local Plugin File" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:16 +#: b43e485ff4f042dd80b5950444c0db08 +msgid "" +"If you want to use a private plug-in developed by yourself, you can " +"upload the plug-in first and then use it. ![Upload Private " +"Plugin](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:16 +#: a05724784c0e45528039b8238fd9ed3c +msgid "Upload Private Plugin" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:19 +#: 726b5c4cad7d4be9815e9fbeedaecc2b +msgid "4.Select installed plug-ins dialog" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:20 +#: e3d9dc892d054cbca29267cd0fffe7be +msgid "" +"Select an installed plugin to have a conversation. ![Select " +"Plugins](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:20 +#: 97f28bacc02444c580f6481b21e6c155 +msgid "Select Plugins" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:23 +#: d0272e7d94d743289fb2c1613ee85c36 +msgid "5.Uninstall My Plugin" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:24 +#: 2fee213a12da4674b19fe8891e4318f5 +msgid "" +"Uninstall plugins you no longer need. ![Uninstall " +"Plugin](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/)" +msgstr "" + +#: ../../getting_started/application/chatagent/chatagent.md:24 +#: 32e5405249134863bcaf85b0ef91260f +msgid "Uninstall Plugin" +msgstr "" + diff --git a/docs/locales/zh_CN/LC_MESSAGES/getting_started/faq/deploy/deploy_faq.po b/docs/locales/zh_CN/LC_MESSAGES/getting_started/faq/deploy/deploy_faq.po index 41f58c015..e8a085390 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/getting_started/faq/deploy/deploy_faq.po +++ b/docs/locales/zh_CN/LC_MESSAGES/getting_started/faq/deploy/deploy_faq.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: DB-GPT 👏👏 0.3.5\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-26 17:47+0800\n" +"POT-Creation-Date: 2023-10-19 19:31+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language: zh_CN\n" @@ -20,12 +20,12 @@ msgstr "" "Generated-By: Babel 2.12.1\n" #: ../../getting_started/faq/deploy/deploy_faq.md:1 -#: ca823e9d6d1d433db7ed15c8273e1b00 +#: fb640f7c38744cbf996dcf7f73f325f6 msgid "Installation FAQ" msgstr "Installation FAQ" #: ../../getting_started/faq/deploy/deploy_faq.md:5 -#: 3803d098c534434f9f513b3a62de54a4 +#: 79fd80e469d14d608554d53a0e0ed2e3 #, fuzzy msgid "" "Q1: execute `pip install -e .` error, found some package cannot find " @@ -35,18 +35,18 @@ msgstr "" "cannot find correct version." #: ../../getting_started/faq/deploy/deploy_faq.md:6 -#: b785864f47e643df9a4669d8da6167d6 +#: f1f6e3291d1446b5bbcf744cd4c4e89a msgid "change the pip source." msgstr "替换pip源." #: ../../getting_started/faq/deploy/deploy_faq.md:13 #: ../../getting_started/faq/deploy/deploy_faq.md:20 -#: c41f026fb1464c71a45d0746c224ecce f70fb69b568d4fc4ad4c4731b2032eaf +#: 68e1b39a08774a81b9061cc5205e4c1c dd34901f446749e998cd34ec5b6c44f4 msgid "or" msgstr "或者" #: ../../getting_started/faq/deploy/deploy_faq.md:27 -#: d179e3d695764f838dc354eb0d978bb3 +#: 0899f0e28dae443b8f912d96c797b79c msgid "" "Q2: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to" " open database file" @@ -55,86 +55,97 @@ msgstr "" " open database file" #: ../../getting_started/faq/deploy/deploy_faq.md:29 -#: 55174e8d247a414e8c6c8861d4707a55 +#: 3e60d8190e49436b8c40b34a67b7bfb3 msgid "make sure you pull latest code or create directory with mkdir pilot/data" msgstr "make sure you pull latest code or create directory with mkdir pilot/data" #: ../../getting_started/faq/deploy/deploy_faq.md:31 -#: dbce9e9cae734a5083a6f0fc28bce7cd +#: baeaae20238842d3b8e4ae5b337198e5 msgid "Q3: The model keeps getting killed." msgstr "Q3: The model keeps getting killed." #: ../../getting_started/faq/deploy/deploy_faq.md:33 -#: 2de5648d2e7546bf85f20f4162003298 +#: eb3936307ad64b19b73483ff9ae126f2 msgid "" "your GPU VRAM size is not enough, try replace your hardware or replace " "other llms." msgstr "GPU显存不够, 增加显存或者换一个显存小的模型" #: ../../getting_started/faq/deploy/deploy_faq.md:35 -#: 47810771cd364964b9b5b8fd85bca4ee +#: f6dba770717041699c73b4cd00d48aad msgid "Q4: How to access website on the public network" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:37 -#: e8c5bac6680648509d528ea6aaf5994e +#: 447d9e9374de44bab6d8a03f2c936676 msgid "" "You can try to use gradio's [network](https://github.com/gradio-" "app/gradio/blob/main/gradio/networking.py) to achieve." msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:48 -#: bb75ec127f574c00a09d92d5206e9357 +#: 5e34dd4dfcf34feeb1815dfa974041d0 msgid "Open `url` with your browser to see the website." msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:50 -#: 5fdb87b84bd94385a1a93dab8d41ebe8 +#: aaef774ce6124021a3862bc0a25d465f msgid "Q5: (Windows) execute `pip install -e .` error" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:52 -#: 31eef51e044044f29f3ad08defa9c305 +#: ec3945df451c4ec2b32ebb476f45c82b msgid "The error log like the following:" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:71 -#: aaba0c3060b443e4b9877f70d78321ce +#: 1df09f6d9f9b4c1a8a32d6e271e5ee39 msgid "" "Download and install `Microsoft C++ Build Tools` from [visual-cpp-build-" "tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:75 -#: 4c8137546e5c4240884f7ea6d9d922bf +#: 251f47bfa5694242a1c9d81a2022b7a0 msgid "Q6: `Torch not compiled with CUDA enabled`" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:82 -#: 01daf14f8c494219b1d9a5af4449951e +#: bc9dfdfc47924a0e8d3ec535e23bf923 msgid "Install [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit-archive)" msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:83 -#: c75e6371911e4d5ca6859e51501c9679 +#: b5a632baa42745bdbee5d6ba516d8d8b msgid "" "Reinstall PyTorch [start-locally](https://pytorch.org/get-started/locally" "/#start-locally) with CUDA support." msgstr "" #: ../../getting_started/faq/deploy/deploy_faq.md:85 -#: 7cfb9003e505445ebb9ed3d015e184e2 +#: 0092fb91642749f5a55b629017c0de6a msgid "Q7: ImportError: cannot import name 'PersistentClient' from 'chromadb'." msgstr "Q7: ImportError: cannot import name 'PersistentClient' from 'chromadb'." #: ../../getting_started/faq/deploy/deploy_faq.md:91 -#: e1d5d5d85ddc480d8d81f7b550848cbf +#: 4aa87418f2a54c138bf3b7ff28a7e776 msgid "" "Q8: pydantic.error_wrappers.ValidationError:1 validation error for " "HuggingFaceEmbeddings.model_kwargs extra not permitted" -msgstr "Q8: pydantic.error_wrappers.ValidationError:1 validation error for " +msgstr "" +"Q8: pydantic.error_wrappers.ValidationError:1 validation error for " "HuggingFaceEmbeddings.model_kwargs extra not permitted" +#: ../../getting_started/faq/deploy/deploy_faq.md:102 +#: 6b690ab272af44f6b126cfe5ce1435ef +msgid "Q9: alembic.util.exc.CommandError: Target database is not up to date." +msgstr "" + +#: ../../getting_started/faq/deploy/deploy_faq.md:103 +#: 223026d3b9124363b695937922d8f8d5 +msgid "delete files in `DB-GPT/pilot/meta_data/alembic/versions/` and reboot." +msgstr "删除`DB-GPT/pilot/meta_data/alembic/versions/`目录下文件" + #~ msgid "" #~ "Q2: When use Mysql, Access denied " #~ "for user 'root@localhost'(using password :NO)" diff --git a/docs/locales/zh_CN/LC_MESSAGES/getting_started/install/cluster/vms/standalone.po b/docs/locales/zh_CN/LC_MESSAGES/getting_started/install/cluster/vms/standalone.po new file mode 100644 index 000000000..a183fb2c4 --- /dev/null +++ b/docs/locales/zh_CN/LC_MESSAGES/getting_started/install/cluster/vms/standalone.po @@ -0,0 +1,117 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2023, csunny +# This file is distributed under the same license as the DB-GPT package. +# FIRST AUTHOR , 2023. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: DB-GPT 👏👏 0.3.9\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-17 17:24+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language: zh_CN\n" +"Language-Team: zh_CN \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.12.1\n" + +#: ../../getting_started/install/cluster/vms/standalone.md:1 +#: 40af95d327574e5ea9a6c29f68a7709c +msgid "Standalone Deployment" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:5 +#: 7ef23971a0d2415a857d5eb9c4d955ac +msgid "Install Prepare" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:12 +#: f3cd2941fa2d49d686fc246237f82e68 +msgid "Create conda environment" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:20 +#: 589d80d5d97044ee93747091904583c5 +msgid "Install Default Requirements" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:26 +#: 1d151e72660644e7b43084ffccb99598 +msgid "Download and Prepare LLM Model and Embedding Model" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:28 +#: 4443c83f8dfa4fdba30929f1e5ecf619 +msgid "If you don't have high performance hardware server" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:30 +#: 33a6ee878a4a467d8bcfe5dfbdcbe184 +msgid "you can use openai api, tongyi api , bard api, etc." +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:39 +#: 7efdb99bc36d42819b1fcd1341b45eef +msgid "set proxy api in .env" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:48 +#: 50154ece70bc421ebe7ac05966369bc8 +msgid "If you have high performance hardware server" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:62 +#: 4f3696ed069a4a84b2d794593df23765 +msgid "Start all services with a single command." +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:67 +#: f5f671962cb14a10aba34c4274d2fc2c +msgid "" +"By default, the \"dbgpt start webserver\" command will start the " +"Webserver, Model Controller, and Model Worker in a single Python process." +" Here, we specify the service to be started on port 6006." +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:69 +#: 4883221a356843f6a6335c25847aecd2 +msgid "" +"View and validate the model service in the command line, you can use the " +"following commands" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:70 +#: 1346eb55d7c647be90a90a867ba04ec3 +msgid "" +"1.list the started model services and deployed Model Workers, you can use" +" the following command" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:74 +#: 8ab332ebce554758952dbe85c68330a9 +msgid "output is:" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:83 +#: efb460bbb70842218f5c056cf05ba1a0 +msgid "The WorkerManager is the management process for Model Workers" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:85 +#: 10e5b79f3d914ee3974b1a0d07962fe2 +msgid "" +"validate the deployed model in the command line, you can use the " +"following command" +msgstr "" + +#: ../../getting_started/install/cluster/vms/standalone.md:89 +#: 39d062e7fea948949c1c5c099893f308 +msgid "" +"Then an interactive page will be launched where you can have a " +"conversation with the deployed LLM in the terminal." +msgstr "" + diff --git a/pilot/base_modules/agent/db/my_plugin_db.py b/pilot/base_modules/agent/db/my_plugin_db.py index b021088db..acfb70e23 100644 --- a/pilot/base_modules/agent/db/my_plugin_db.py +++ b/pilot/base_modules/agent/db/my_plugin_db.py @@ -9,7 +9,10 @@ from pilot.base_modules.meta_data.meta_data import Base, engine, session class MyPluginEntity(Base): __tablename__ = "my_plugin" - + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } id = Column(Integer, primary_key=True, comment="autoincrement id") tenant = Column(String(255), nullable=True, comment="user's tenant") user_code = Column(String(255), nullable=False, comment="user code") @@ -27,7 +30,7 @@ class MyPluginEntity(Base): created_at = Column( DateTime, default=datetime.utcnow, comment="plugin install time" ) - __table_args__ = (UniqueConstraint("user_code", "name", name="uk_name"),) + UniqueConstraint("user_code", "name", name="uk_name") class MyPluginDao(BaseDao[MyPluginEntity]): diff --git a/pilot/base_modules/agent/db/plugin_hub_db.py b/pilot/base_modules/agent/db/plugin_hub_db.py index 8507bcc8e..89ec314c7 100644 --- a/pilot/base_modules/agent/db/plugin_hub_db.py +++ b/pilot/base_modules/agent/db/plugin_hub_db.py @@ -1,7 +1,7 @@ from datetime import datetime import pytz from typing import List -from sqlalchemy import Column, Integer, String, Index, DateTime, func, Boolean +from sqlalchemy import Column, Integer, String, Index, DateTime, func, Boolean, DDL from sqlalchemy import UniqueConstraint from pilot.base_modules.meta_data.meta_data import Base @@ -9,8 +9,15 @@ from pilot.base_modules.meta_data.base_dao import BaseDao from pilot.base_modules.meta_data.meta_data import Base, engine, session +char_set_sql = DDL("ALTER TABLE plugin_hub CONVERT TO CHARACTER SET utf8mb4") + + class PluginHubEntity(Base): __tablename__ = "plugin_hub" + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } id = Column( Integer, primary_key=True, autoincrement=True, comment="autoincrement id" ) @@ -26,10 +33,8 @@ class PluginHubEntity(Base): created_at = Column(DateTime, default=datetime.utcnow, comment="plugin upload time") installed = Column(Integer, default=False, comment="plugin already installed count") - __table_args__ = ( - UniqueConstraint("name", name="uk_name"), - Index("idx_q_type", "type"), - ) + UniqueConstraint("name", name="uk_name") + Index("idx_q_type", "type") class PluginHubDao(BaseDao[PluginHubEntity]): diff --git a/pilot/connections/manages/connection_manager.py b/pilot/connections/manages/connection_manager.py index 9b66d0501..340c58f0b 100644 --- a/pilot/connections/manages/connection_manager.py +++ b/pilot/connections/manages/connection_manager.py @@ -154,7 +154,7 @@ class ConnectManager: db_type = DBType.of_db_type(db_info.db_type) connect_instance = self.get_cls_by_dbtype(db_type.value()) if db_type.is_file_db(): - db_path = db_info.db_path + db_path = db_info.file_path return connect_instance.from_file_path(db_path) else: db_name = db_info.db_name diff --git a/pilot/connections/rdbms/base.py b/pilot/connections/rdbms/base.py index b590294ac..82798a885 100644 --- a/pilot/connections/rdbms/base.py +++ b/pilot/connections/rdbms/base.py @@ -52,7 +52,18 @@ class RDBMSDatabase(BaseConnect): custom_table_info: Optional[dict] = None, view_support: bool = False, ): - """Create engine from database URI.""" + """Create engine from database URI. + Args: + - engine: Engine sqlalchemy.engine + - schema: Optional[str]. + - metadata: Optional[MetaData] + - ignore_tables: Optional[List[str]] + - include_tables: Optional[List[str]] + - sample_rows_in_table_info: int default:3, + - indexes_in_table_info: bool = False, + - custom_table_info: Optional[dict] = None, + - view_support: bool = False, + """ self._engine = engine self._schema = schema if include_tables and ignore_tables: @@ -92,6 +103,15 @@ class RDBMSDatabase(BaseConnect): engine_args: Optional[dict] = None, **kwargs: Any, ) -> RDBMSDatabase: + """Construct a SQLAlchemy engine from uri database. + Args: + host (str): database host. + port (int): database port. + user (str): database user. + pwd (str): database password. + db_name (str): database name. + engine_args (Optional[dict]):other engine_args. + """ db_url: str = ( cls.driver + "://" @@ -329,7 +349,7 @@ class RDBMSDatabase(BaseConnect): def run(self, command: str, fetch: str = "all") -> List: """Execute a SQL command and return a string representing the results.""" print("SQL:" + command) - if not command: + if not command or len(command) <0: return [] parsed, ttype, sql_type, table_name = self.__sql_parse(command) if ttype == sqlparse.tokens.DML: diff --git a/pilot/embedding_engine/csv_embedding.py b/pilot/embedding_engine/csv_embedding.py index 5f58fac9d..efd6b905e 100644 --- a/pilot/embedding_engine/csv_embedding.py +++ b/pilot/embedding_engine/csv_embedding.py @@ -21,7 +21,13 @@ class CSVEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize with csv path.""" + """Initialize with csv path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path, vector_store_config, source_reader=None, text_splitter=None ) diff --git a/pilot/embedding_engine/embedding_engine.py b/pilot/embedding_engine/embedding_engine.py index 77d1a6667..ce739c3bb 100644 --- a/pilot/embedding_engine/embedding_engine.py +++ b/pilot/embedding_engine/embedding_engine.py @@ -28,7 +28,16 @@ class EmbeddingEngine: text_splitter: Optional[TextSplitter] = None, embedding_factory: EmbeddingFactory = None, ): - """Initialize with knowledge embedding client, model_name, vector_store_config, knowledge_type, knowledge_source""" + """Initialize with knowledge embedding client, model_name, vector_store_config, knowledge_type, knowledge_source + Args: + - model_name: model_name + - vector_store_config: vector store config: Dict + - knowledge_type: Optional[KnowledgeType] + - knowledge_source: Optional[str] + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + - embedding_factory: EmbeddingFactory + """ self.knowledge_source = knowledge_source self.model_name = model_name self.vector_store_config = vector_store_config @@ -65,6 +74,11 @@ class EmbeddingEngine: ) def similar_search(self, text, topk): + """vector db similar search + Args: + - text: query text + - topk: top k + """ vector_client = VectorStoreConnector( self.vector_store_config["vector_store_type"], self.vector_store_config ) @@ -75,12 +89,17 @@ class EmbeddingEngine: return ans def vector_exist(self): + """vector db is exist""" vector_client = VectorStoreConnector( self.vector_store_config["vector_store_type"], self.vector_store_config ) return vector_client.vector_name_exists() def delete_by_ids(self, ids): + """delete vector db by ids + Args: + - ids: vector ids + """ vector_client = VectorStoreConnector( self.vector_store_config["vector_store_type"], self.vector_store_config ) diff --git a/pilot/embedding_engine/pdf_embedding.py b/pilot/embedding_engine/pdf_embedding.py index bb62cb708..1f603d284 100644 --- a/pilot/embedding_engine/pdf_embedding.py +++ b/pilot/embedding_engine/pdf_embedding.py @@ -23,7 +23,13 @@ class PDFEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize pdf word path.""" + """Initialize pdf word path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path, vector_store_config, source_reader=None, text_splitter=None ) diff --git a/pilot/embedding_engine/ppt_embedding.py b/pilot/embedding_engine/ppt_embedding.py index 9058c092f..42137d91d 100644 --- a/pilot/embedding_engine/ppt_embedding.py +++ b/pilot/embedding_engine/ppt_embedding.py @@ -23,7 +23,13 @@ class PPTEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize ppt word path.""" + """Initialize ppt word path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path, vector_store_config, source_reader=None, text_splitter=None ) diff --git a/pilot/embedding_engine/source_embedding.py b/pilot/embedding_engine/source_embedding.py index 24bae97b2..950c84ded 100644 --- a/pilot/embedding_engine/source_embedding.py +++ b/pilot/embedding_engine/source_embedding.py @@ -29,7 +29,14 @@ class SourceEmbedding(ABC): text_splitter: Optional[TextSplitter] = None, embedding_args: Optional[Dict] = None, ): - """Initialize with Loader url, model_name, vector_store_config""" + """Initialize with Loader url, model_name, vector_store_config + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + - embedding_args: Optional + """ self.file_path = file_path self.vector_store_config = vector_store_config self.source_reader = source_reader or None @@ -44,21 +51,33 @@ class SourceEmbedding(ABC): @register def data_process(self, text): - """pre process data.""" + """pre process data. + Args: + - text: raw text + """ @register def text_splitter(self, text_splitter: TextSplitter): - """add text split chunk""" + """add text split chunk + Args: + - text_splitter: TextSplitter + """ pass @register def text_to_vector(self, docs): - """transform vector""" + """transform vector + Args: + - docs: List[Document] + """ pass @register def index_to_store(self, docs): - """index to vector store""" + """index to vector store + Args: + - docs: List[Document] + """ self.vector_client = VectorStoreConnector( self.vector_store_config["vector_store_type"], self.vector_store_config ) @@ -66,7 +85,10 @@ class SourceEmbedding(ABC): @register def similar_search(self, doc, topk): - """vector store similarity_search""" + """vector store similarity_search + Args: + - query: query + """ self.vector_client = VectorStoreConnector( self.vector_store_config["vector_store_type"], self.vector_store_config ) @@ -82,6 +104,7 @@ class SourceEmbedding(ABC): return self.vector_client.vector_name_exists() def source_embedding(self): + """read()->data_process()->text_split()->index_to_store()""" if "read" in registered_methods: text = self.read() if "data_process" in registered_methods: diff --git a/pilot/embedding_engine/string_embedding.py b/pilot/embedding_engine/string_embedding.py index 95e7ba6d1..fafdb27f2 100644 --- a/pilot/embedding_engine/string_embedding.py +++ b/pilot/embedding_engine/string_embedding.py @@ -20,7 +20,13 @@ class StringEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize raw text word path.""" + """Initialize raw text word path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path=file_path, vector_store_config=vector_store_config, diff --git a/pilot/embedding_engine/url_embedding.py b/pilot/embedding_engine/url_embedding.py index e00cf84e2..71842c2f1 100644 --- a/pilot/embedding_engine/url_embedding.py +++ b/pilot/embedding_engine/url_embedding.py @@ -22,7 +22,13 @@ class URLEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize url word path.""" + """Initialize url word path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path, vector_store_config, source_reader=None, text_splitter=None ) diff --git a/pilot/embedding_engine/word_embedding.py b/pilot/embedding_engine/word_embedding.py index aba50fe24..5bfe7ec88 100644 --- a/pilot/embedding_engine/word_embedding.py +++ b/pilot/embedding_engine/word_embedding.py @@ -23,7 +23,13 @@ class WordEmbedding(SourceEmbedding): source_reader: Optional = None, text_splitter: Optional[TextSplitter] = None, ): - """Initialize with word path.""" + """Initialize with word path. + Args: + - file_path: data source path + - vector_store_config: vector store config params. + - source_reader: Optional[BaseLoader] + - text_splitter: Optional[TextSplitter] + """ super().__init__( file_path, vector_store_config, source_reader=None, text_splitter=None ) diff --git a/pilot/memory/chat_history/chat_history_db.py b/pilot/memory/chat_history/chat_history_db.py index 2b1a57c28..2f9b2999c 100644 --- a/pilot/memory/chat_history/chat_history_db.py +++ b/pilot/memory/chat_history/chat_history_db.py @@ -10,6 +10,10 @@ class ChatHistoryEntity(Base): id = Column( Integer, primary_key=True, autoincrement=True, comment="autoincrement id" ) + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } conv_uid = Column( String(255), unique=False, @@ -21,12 +25,10 @@ class ChatHistoryEntity(Base): user_name = Column(String(255), nullable=True, comment="interlocutor") messages = Column(Text, nullable=True, comment="Conversation details") - __table_args__ = ( - UniqueConstraint("conv_uid", name="uk_conversation"), - Index("idx_q_user", "user_name"), - Index("idx_q_mode", "chat_mode"), - Index("idx_q_conv", "summary"), - ) + UniqueConstraint("conv_uid", name="uk_conversation") + Index("idx_q_user", "user_name") + Index("idx_q_mode", "chat_mode") + Index("idx_q_conv", "summary") class ChatHistoryDao(BaseDao[ChatHistoryEntity]): diff --git a/pilot/model/cluster/controller/controller.py b/pilot/model/cluster/controller/controller.py index 7751ddb5a..35a91ee3c 100644 --- a/pilot/model/cluster/controller/controller.py +++ b/pilot/model/cluster/controller/controller.py @@ -185,7 +185,7 @@ def run_model_controller(): setup_logging( "pilot", logging_level=controller_params.log_level, - logger_filename="dbgpt_model_controller.log", + logger_filename=controller_params.log_file, ) initialize_controller(host=controller_params.host, port=controller_params.port) diff --git a/pilot/model/cluster/worker/manager.py b/pilot/model/cluster/worker/manager.py index 815f07bf2..cc5ef97d6 100644 --- a/pilot/model/cluster/worker/manager.py +++ b/pilot/model/cluster/worker/manager.py @@ -1006,7 +1006,7 @@ def run_worker_manager( setup_logging( "pilot", logging_level=worker_params.log_level, - logger_filename="dbgpt_model_worker_manager.log", + logger_filename=worker_params.log_file, ) embedded_mod = True @@ -1019,7 +1019,7 @@ def run_worker_manager( system_app = SystemApp(app) initialize_tracer( system_app, - os.path.join(LOGDIR, "dbgpt_model_worker_manager_tracer.jsonl"), + os.path.join(LOGDIR, worker_params.tracer_file), root_operation_name="DB-GPT-WorkerManager-Entry", ) diff --git a/pilot/model/parameter.py b/pilot/model/parameter.py index 0ad048c24..ba0000435 100644 --- a/pilot/model/parameter.py +++ b/pilot/model/parameter.py @@ -46,6 +46,18 @@ class ModelControllerParameters(BaseParameters): ], }, ) + log_file: Optional[str] = field( + default="dbgpt_model_controller.log", + metadata={ + "help": "The filename to store log", + }, + ) + tracer_file: Optional[str] = field( + default="dbgpt_model_controller_tracer.jsonl", + metadata={ + "help": "The filename to store tracer span records", + }, + ) @dataclass @@ -122,6 +134,18 @@ class ModelWorkerParameters(BaseModelParameters): ], }, ) + log_file: Optional[str] = field( + default="dbgpt_model_worker_manager.log", + metadata={ + "help": "The filename to store log", + }, + ) + tracer_file: Optional[str] = field( + default="dbgpt_model_worker_manager_tracer.jsonl", + metadata={ + "help": "The filename to store tracer span records", + }, + ) @dataclass diff --git a/pilot/openapi/api_v1/feedback/feed_back_db.py b/pilot/openapi/api_v1/feedback/feed_back_db.py index 2b57c4bde..3d697263b 100644 --- a/pilot/openapi/api_v1/feedback/feed_back_db.py +++ b/pilot/openapi/api_v1/feedback/feed_back_db.py @@ -1,16 +1,18 @@ from datetime import datetime from sqlalchemy import Column, Integer, Text, String, DateTime -from sqlalchemy.ext.declarative import declarative_base -from pilot.connections.rdbms.base_dao import BaseDao +from pilot.base_modules.meta_data.base_dao import BaseDao +from pilot.base_modules.meta_data.meta_data import Base, engine, session from pilot.openapi.api_v1.feedback.feed_back_model import FeedBackBody -Base = declarative_base() - class ChatFeedBackEntity(Base): __tablename__ = "chat_feed_back" + __table_args__ = { + "mysql_charset": "utf8mb4", + "mysql_collate": "utf8mb4_unicode_ci", + } id = Column(Integer, primary_key=True) conv_uid = Column(String(128)) conv_index = Column(Integer) @@ -33,13 +35,15 @@ class ChatFeedBackEntity(Base): class ChatFeedBackDao(BaseDao): def __init__(self): - super().__init__(database="history", orm_base=Base, create_not_exist_table=True) + super().__init__( + database="dbgpt", orm_base=Base, db_engine=engine, session=session + ) def create_or_update_chat_feed_back(self, feed_back: FeedBackBody): # Todo: We need to have user information first. def_user_name = "" - session = self.Session() + session = self.get_session() chat_feed_back = ChatFeedBackEntity( conv_uid=feed_back.conv_uid, conv_index=feed_back.conv_index, @@ -73,7 +77,7 @@ class ChatFeedBackDao(BaseDao): session.close() def get_chat_feed_back(self, conv_uid: str, conv_index: int): - session = self.Session() + session = self.get_session() result = ( session.query(ChatFeedBackEntity) .filter(ChatFeedBackEntity.conv_uid == conv_uid) diff --git a/pilot/scene/base_chat.py b/pilot/scene/base_chat.py index 26c1f0aa6..5d685573e 100644 --- a/pilot/scene/base_chat.py +++ b/pilot/scene/base_chat.py @@ -21,6 +21,12 @@ CFG = Config() class BaseChat(ABC): + """DB-GPT Chat Service Base Module + Include: + stream_call():scene + prompt -> stream response + nostream_call():scene + prompt -> nostream response + """ + chat_scene: str = None llm_model: Any = None # By default, keep the last two rounds of conversation records as the context @@ -32,6 +38,14 @@ class BaseChat(ABC): arbitrary_types_allowed = True def __init__(self, chat_param: Dict): + """Chat Module Initialization + Args: + - chat_param: Dict + - chat_session_id: (str) chat session_id + - current_user_input: (str) current user input + - model_name:(str) llm model name + - select_param:(str) select param + """ self.chat_session_id = chat_param["chat_session_id"] self.chat_mode = chat_param["chat_mode"] self.current_user_input: str = chat_param["current_user_input"] @@ -359,7 +373,10 @@ class BaseChat(ABC): ) if len(self.history_message) > self.chat_retention_rounds: for first_message in self.history_message[0]["messages"]: - if not first_message["type"] in [ModelMessageRoleType.VIEW, ModelMessageRoleType.SYSTEM]: + if not first_message["type"] in [ + ModelMessageRoleType.VIEW, + ModelMessageRoleType.SYSTEM, + ]: message_type = first_message["type"] message_content = first_message["data"]["content"] history_text += ( diff --git a/pilot/scene/chat_agent/chat.py b/pilot/scene/chat_agent/chat.py index 4734c8106..0fc5a0375 100644 --- a/pilot/scene/chat_agent/chat.py +++ b/pilot/scene/chat_agent/chat.py @@ -18,10 +18,20 @@ logger = logging.getLogger("chat_agent") class ChatAgent(BaseChat): + """Chat With Agent through plugin""" + chat_scene: str = ChatScene.ChatAgent.value() chat_retention_rounds = 0 def __init__(self, chat_param: Dict): + """Chat Agent Module Initialization + Args: + - chat_param: Dict + - chat_session_id: (str) chat session_id + - current_user_input: (str) current user input + - model_name:(str) llm model name + - select_param:(str) agent plugin + """ if not chat_param["select_param"]: raise ValueError("Please select a Plugin!") self.select_plugins = chat_param["select_param"].split(",") @@ -53,7 +63,6 @@ class ChatAgent(BaseChat): def stream_plugin_call(self, text): text = text.replace("\n", " ") - print(f"stream_plugin_call:{text}") return self.api_call.run(text) def __list_to_prompt_str(self, list: List) -> str: diff --git a/pilot/scene/chat_dashboard/chat.py b/pilot/scene/chat_dashboard/chat.py index ba5bdd8ce..7e4433670 100644 --- a/pilot/scene/chat_dashboard/chat.py +++ b/pilot/scene/chat_dashboard/chat.py @@ -19,10 +19,17 @@ CFG = Config() class ChatDashboard(BaseChat): chat_scene: str = ChatScene.ChatDashboard.value() report_name: str - """Number of results to return from the query""" + """Chat Dashboard to generate dashboard chart""" def __init__(self, chat_param: Dict): - """ """ + """Chat Dashboard Module Initialization + Args: + - chat_param: Dict + - chat_session_id: (str) chat session_id + - current_user_input: (str) current user input + - model_name:(str) llm model name + - select_param:(str) dbname + """ self.db_name = chat_param["select_param"] chat_param["chat_mode"] = ChatScene.ChatDashboard super().__init__(chat_param=chat_param) diff --git a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py index 9599c1402..9a316cd34 100644 --- a/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py +++ b/pilot/scene/chat_data/chat_excel/excel_analyze/chat.py @@ -19,10 +19,20 @@ CFG = Config() class ChatExcel(BaseChat): + """a Excel analyzer to analyze Excel Data""" + chat_scene: str = ChatScene.ChatExcel.value() chat_retention_rounds = 1 def __init__(self, chat_param: Dict): + """Chat Excel Module Initialization + Args: + - chat_param: Dict + - chat_session_id: (str) chat session_id + - current_user_input: (str) current user input + - model_name:(str) llm model name + - select_param:(str) file path + """ chat_mode = ChatScene.ChatExcel self.select_param = chat_param["select_param"] @@ -78,5 +88,4 @@ class ChatExcel(BaseChat): def stream_plugin_call(self, text): text = text.replace("\n", " ") - print(f"stream_plugin_call:{text}") return self.api_call.run_display_sql(text, self.excel_reader.get_df_by_sql_ex) diff --git a/pilot/scene/chat_db/auto_execute/chat.py b/pilot/scene/chat_db/auto_execute/chat.py index 8f4c0b673..01e04be63 100644 --- a/pilot/scene/chat_db/auto_execute/chat.py +++ b/pilot/scene/chat_db/auto_execute/chat.py @@ -16,6 +16,14 @@ class ChatWithDbAutoExecute(BaseChat): """Number of results to return from the query""" def __init__(self, chat_param: Dict): + """Chat Data Module Initialization + Args: + - chat_param: Dict + - chat_session_id: (str) chat session_id + - current_user_input: (str) current user input + - model_name:(str) llm model name + - select_param:(str) dbname + """ chat_mode = ChatScene.ChatWithDbExecute self.db_name = chat_param["select_param"] chat_param["chat_mode"] = chat_mode @@ -33,6 +41,9 @@ class ChatWithDbAutoExecute(BaseChat): self.api_call = ApiCall(display_registry=CFG.command_disply) def generate_input_values(self): + """ + generate input values + """ try: from pilot.summary.db_summary_client import DBSummaryClient except ImportError: diff --git a/pilot/scene/chat_db/auto_execute/out_parser.py b/pilot/scene/chat_db/auto_execute/out_parser.py index 03c71b431..577cac1ef 100644 --- a/pilot/scene/chat_db/auto_execute/out_parser.py +++ b/pilot/scene/chat_db/auto_execute/out_parser.py @@ -36,8 +36,8 @@ class DbChatOutputParser(BaseOutputParser): ### tool out data to table view data_loader = DbDataLoader() - if len(data) <= 1: - data.insert(0, ["result"]) + if len(data) < 1: + data.insert(0, []) df = pd.DataFrame(data[1:], columns=data[0]) if not CFG.NEW_SERVER_MODE and not CFG.SERVER_LIGHT_MODE: table_style = """