diff --git a/assets/chat_agent/__init__.py b/assets/chat_agent/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/assets/chat_agent/chat_agent1.png b/assets/chat_agent/chat_agent1.png new file mode 100644 index 000000000..af3f1c715 Binary files /dev/null and b/assets/chat_agent/chat_agent1.png differ diff --git a/docs/getting_started/application/chatagent/chatagent.md b/docs/getting_started/application/chatagent/chatagent.md new file mode 100644 index 000000000..f59d335f0 --- /dev/null +++ b/docs/getting_started/application/chatagent/chatagent.md @@ -0,0 +1,23 @@ +ChatAgent +================================== +ChatAgent can automatically select the right tool to answer and solve user problems through LLM. +![db plugins demonstration](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/d8bfeee9-e982-465e-a2b8-1164b673847e) + +### 1.Update Plugins From Git + +![db plugins demonstration](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/7678f07e-9eee-40a9-b980-5b3978a0ed52) + + +### 2.Install Plugin +After successfully setting up the data source, you can start conversing with the database. You can ask it to generate +SQL for you or inquire about relevant information on the database's metadata. +![db plugins demonstration](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/8acf6a42-e511-48ff-aabf-3d9037485c1c) + + +### 3.Upload My Local Plugin File + +### 4.Select installed plug-ins dialog + +![db plugins demonstration](https://github.com/eosphoros-ai/DB-GPT/assets/13723926/e04bc1b1-2c58-4b33-af62-97e89098ace7) + +### 5.Uninstall My Plugin diff --git a/docs/use_cases/tool_use_with_plugin.md b/docs/use_cases/tool_use_with_plugin.md index 705062c00..93d665c89 100644 --- a/docs/use_cases/tool_use_with_plugin.md +++ b/docs/use_cases/tool_use_with_plugin.md @@ -1,13 +1,13 @@ # Tool use with plugin -- DB-GPT supports a variety of plug-ins, such as MySQL, MongoDB, ClickHouse and other database tool plug-ins. In addition, some database management platforms can also package their interfaces and package them into plug-ins, and use the model to realize the ability of "single-sentence requirements" +- DB-GPT supports a variety of plug-ins, such as BaiduSearch, SendEmail. In addition, some database management platforms can also package their interfaces and package them into plug-ins, and use the model to realize the ability of "single-sentence requirements" -## DB-GPT-DASHBOARD-PLUGIN +## Baidu-Search-Plugin -[](https://github.com/csunny/DB-GPT-Plugins/blob/main/src/dbgpt_plugins/Readme.md) +[Db-GPT Plugins](https://github.com/eosphoros-ai/DB-GPT-Plugins/blob/main/src/dbgpt_plugins/Readme.md) -- This is a DB-GPT plugin to generate data analysis charts, if you want to use the test sample data, please first pull the code of [DB-GPT-Plugins](https://github.com/csunny/DB-GPT-Plugins), run the command to generate test DuckDB data, and then copy the generated data file to the `/pilot/mock_datas` directory of the DB-GPT project. +- Perform search queries using the Baidu search engine [DB-GPT-Plugins](https://github.com/eosphoros-ai/DB-GPT-Plugins). ```bash git clone https://github.com/csunny/DB-GPT-Plugins.git @@ -23,35 +23,5 @@ python /DB-GPT/pilot/webserver.py

-- More detail see: [DB-DASHBOARD](https://github.com/csunny/DB-GPT-Plugins/blob/main/src/dbgpt_plugins/Readme.md) - - -## DB-GPT-SQL-Execution-Plugin - - -- This is an DbGPT plugin to connect Generic Db And Execute SQL. - - -## DB-GPT-Bytebase-Plugin - -- To use a tool or platform plugin, you should first deploy a plugin. Taking the open-source database management platform Bytebase as an example, you can deploy your Bytebase service with one click using Docker and access it at http://127.0.0.1:5678. More details can be found at https://github.com/bytebase/bytebase. -```bash -docker run --init \ - --name bytebase \ - --platform linux/amd64 \ - --restart always \ - --publish 5678:8080 \ - --health-cmd "curl --fail http://localhost:5678/healthz || exit 1" \ - --health-interval 5m \ - --health-timeout 60s \ - --volume ~/.bytebase/data:/var/opt/bytebase \ - bytebase/bytebase:2.2.0 \ - --data /var/opt/bytebase \ - --port 8080 -``` - -Note: If your machine's CPU architecture is `ARM`, please use `--platform linux/arm64` instead. - -- Select the plugin on DB-GPT(All built-in plugins are from our repository: https://github.com/csunny/DB-GPT-Plugins),choose DB-GPT-Bytebase-Plugin. -Supporting functions include creating projects, creating environments, creating database instances, creating databases, database DDL/DML operations, and ticket approval process, etc. +- More detail see: [DB-DASHBOARD](https://github.com/eosphoros-ai/DB-GPT-Plugins/blob/main/src/dbgpt_plugins/Readme.md) diff --git a/pilot/base_modules/agent/db/my_plugin_db.py b/pilot/base_modules/agent/db/my_plugin_db.py index 8661d6f70..9466ec629 100644 --- a/pilot/base_modules/agent/db/my_plugin_db.py +++ b/pilot/base_modules/agent/db/my_plugin_db.py @@ -71,6 +71,20 @@ class MyPluginDao(BaseDao[MyPluginEntity]): session.close() return result + def get_by_user_and_plugin(self, user: str, plugin: str) -> MyPluginEntity: + session = self.get_session() + my_plugins = session.query(MyPluginEntity) + if user: + my_plugins = my_plugins.filter( + MyPluginEntity.user_code == user + ) + my_plugins = my_plugins.filter( + MyPluginEntity.name == plugin + ) + result = my_plugins.first() + session.close() + return result + def list(self, query: MyPluginEntity, page=1, page_size=20)->list[MyPluginEntity]: session = self.get_session() diff --git a/pilot/base_modules/agent/hub/agent_hub.py b/pilot/base_modules/agent/hub/agent_hub.py index b61158a40..3af9c722e 100644 --- a/pilot/base_modules/agent/hub/agent_hub.py +++ b/pilot/base_modules/agent/hub/agent_hub.py @@ -21,7 +21,7 @@ TEMP_PLUGIN_PATH = "" class AgentHub: def __init__(self, plugin_dir) -> None: self.hub_dao = PluginHubDao() - self.my_lugin_dao = MyPluginDao() + self.my_plugin_dao = MyPluginDao() os.makedirs(plugin_dir, exist_ok=True) self.plugin_dir = plugin_dir self.temp_hub_file_path = os.path.join(plugin_dir, "temp") @@ -43,11 +43,13 @@ class AgentHub: # add to my plugins and edit hub status plugin_entity.installed = plugin_entity.installed + 1 - my_plugin_entity = self.__build_my_plugin(plugin_entity) + my_plugin_entity = self.my_plugin_dao.get_by_user_and_plugin(user_name, plugin_name) + if my_plugin_entity is None: + my_plugin_entity = self.__build_my_plugin(plugin_entity) my_plugin_entity.file_name = file_name if user_name: # TODO use user - my_plugin_entity.user_code = "" + my_plugin_entity.user_code = user_name my_plugin_entity.user_name = user_name my_plugin_entity.tenant = "" else: @@ -55,11 +57,15 @@ class AgentHub: with self.hub_dao.get_session() as session: try: - session.add(my_plugin_entity) + if my_plugin_entity.id is None: + session.add(my_plugin_entity) + else: + session.merge(my_plugin_entity) session.merge(plugin_entity) session.commit() session.close() - except: + except Exception as e: + logger.error("install merge roll back!" + str(e)) session.rollback() except Exception as e: logger.error("install pluguin exception!", e) @@ -72,29 +78,39 @@ class AgentHub: def uninstall_plugin(self, plugin_name, user): logger.info(f"uninstall_plugin:{plugin_name},{user}") plugin_entity = self.hub_dao.get_by_name(plugin_name) - plugin_entity.installed = plugin_entity.installed - 1 + my_plugin_entity = self.my_plugin_dao.get_by_user_and_plugin(user, plugin_name) + if plugin_entity is not None: + plugin_entity.installed = plugin_entity.installed - 1 with self.hub_dao.get_session() as session: try: my_plugin_q = session.query(MyPluginEntity).filter(MyPluginEntity.name == plugin_name) if user: my_plugin_q.filter(MyPluginEntity.user_code == user) my_plugin_q.delete() - session.merge(plugin_entity) + if plugin_entity is not None: + session.merge(plugin_entity) session.commit() except: session.rollback() - # delete package file if not use - plugin_infos = self.hub_dao.get_by_storage_url(plugin_entity.storage_url) - have_installed = False - for plugin_info in plugin_infos: - if plugin_info.installed > 0: - have_installed = True - break - if not have_installed: - plugin_repo_name = plugin_entity.storage_url.replace(".git", "").strip('/').split('/')[-1] + if plugin_entity is not None: + # delete package file if not use + plugin_infos = self.hub_dao.get_by_storage_url(plugin_entity.storage_url) + have_installed = False + for plugin_info in plugin_infos: + if plugin_info.installed > 0: + have_installed = True + break + if not have_installed: + plugin_repo_name = plugin_entity.storage_url.replace(".git", "").strip('/').split('/')[-1] + files = glob.glob( + os.path.join(self.plugin_dir, f"{plugin_repo_name}*") + ) + for file in files: + os.remove(file) + else: files = glob.glob( - os.path.join(self.plugin_dir, f"{plugin_repo_name}*") + os.path.join(self.plugin_dir, f"{my_plugin_entity.file_name}") ) for file in files: os.remove(file) @@ -162,8 +178,9 @@ class AgentHub: user = Default_User for my_plugin in my_plugins: - my_plugin_entiy = MyPluginEntity() - + my_plugin_entiy = self.my_plugin_dao.get_by_user_and_plugin(user, my_plugin._name) + if my_plugin_entiy is None : + my_plugin_entiy = MyPluginEntity() my_plugin_entiy.name = my_plugin._name my_plugin_entiy.version = my_plugin._version my_plugin_entiy.type = "Personal" @@ -171,8 +188,7 @@ class AgentHub: my_plugin_entiy.user_name = user my_plugin_entiy.tenant = "" my_plugin_entiy.file_name = doc_file.filename - - self.my_lugin_dao.update(my_plugin_entiy) + self.my_plugin_dao.update(my_plugin_entiy) def reload_my_plugins(self): logger.info(f"load_plugins start!") @@ -182,5 +198,5 @@ class AgentHub: logger.info(f"get_my_plugin:{user}") if not user: user = Default_User - return self.my_lugin_dao.get_by_user(user) + return self.my_plugin_dao.get_by_user(user) diff --git a/pilot/server/static/404.html b/pilot/server/static/404.html index 959f6bb13..b5df64a0b 100644 --- a/pilot/server/static/404.html +++ b/pilot/server/static/404.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/pilot/server/static/404/index.html b/pilot/server/static/404/index.html index 959f6bb13..b5df64a0b 100644 --- a/pilot/server/static/404/index.html +++ b/pilot/server/static/404/index.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_buildManifest.js b/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_buildManifest.js new file mode 100644 index 000000000..9aa555544 --- /dev/null +++ b/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_buildManifest.js @@ -0,0 +1 @@ +self.__BUILD_MANIFEST=function(s,c,t,a,e,d,f,n,i,u,b,h,k,j,r,o,p,_,g){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[t,s,c,a,e,f,b,h,"static/chunks/539-dcd22f1f6b99ebee.js","static/chunks/pages/index-5f6b7fd392ff6866.js"],"/_error":["static/chunks/pages/_error-dee72aff9b2e2c12.js"],"/agent":[s,a,e,i,k,"static/chunks/pages/agent-bf06b377cbd5be86.js"],"/chat/[scene]/[id]":["static/chunks/pages/chat/[scene]/[id]-76515749283bf0a9.js"],"/database":[s,c,a,e,i,b,j,k,"static/chunks/643-d2492f894de95084.js","static/chunks/pages/database-671d42822e30d06f.js"],"/datastores":[t,d,n,u,r,o,p,"static/chunks/pages/datastores-934c240249d280f8.js"],"/datastores/documents":[t,_,s,c,d,n,f,u,r,i,o,p,g,"static/chunks/749-fac3e13c5ab7cff1.js","static/chunks/pages/datastores/documents-cabe6fd9ceb2a4bf.js"],"/datastores/documents/chunklist":[t,s,c,d,f,u,g,"static/chunks/pages/datastores/documents/chunklist-9f3e07d54af4b48c.js"],"/models":[_,s,c,a,d,e,n,j,"static/chunks/991-0cfc6e4020e4d683.js","static/chunks/pages/models-23fdae75ae8c0351.js"],"/prompt":[t,s,c,a,d,e,n,f,"static/chunks/45-b98c4238ff6e0cc1.js",h,"static/chunks/61-4b1a896c7810d559.js","static/chunks/367-88244d673d2fa27b.js","static/chunks/pages/prompt-031e47fc3f1ed3cc.js"],sortedPages:["/","/_app","/_error","/agent","/chat/[scene]/[id]","/database","/datastores","/datastores/documents","/datastores/documents/chunklist","/models","/prompt"]}}("static/chunks/347-4d8f7092e4bdfdfb.js","static/chunks/9-8bf443a54ad1b325.js","static/chunks/29107295-90b90cb30c825230.js","static/chunks/566-074186f7bac9291d.js","static/chunks/479-68b22ee2b7a47fb3.js","static/chunks/262-301259b7bd25a2f2.js","static/chunks/647-f9d834aad2c525c1.js","static/chunks/737-8b1fcf8b6e843f49.js","static/chunks/442-197e6cbc1e54109a.js","static/chunks/995-2f502d60cecceeb6.js","static/chunks/411-d9eba2657c72f766.js","static/chunks/615-2e05a69bfa343278.js","static/chunks/813-cce9482e33f2430c.js","static/chunks/928-74244889bd7f2699.js","static/chunks/341-20a63c15c7f45eaf.js","static/chunks/655-1c948938dfd927ff.js","static/chunks/387-03259b62c3d128f7.js","static/chunks/75fc9c18-a784766a129ec5fb.js","static/chunks/963-0ad205f64dc9848d.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_ssgManifest.js b/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_ssgManifest.js new file mode 100644 index 000000000..5b3ff592f --- /dev/null +++ b/pilot/server/static/_next/static/tDQauwg72WMp4dlX9SXqU/_ssgManifest.js @@ -0,0 +1 @@ +self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB() \ No newline at end of file diff --git a/pilot/server/static/agent/index.html b/pilot/server/static/agent/index.html index bff9e3534..d6334261e 100644 --- a/pilot/server/static/agent/index.html +++ b/pilot/server/static/agent/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/chat/[scene]/[id]/index.html b/pilot/server/static/chat/[scene]/[id]/index.html index 89eb05668..74fd5e347 100644 --- a/pilot/server/static/chat/[scene]/[id]/index.html +++ b/pilot/server/static/chat/[scene]/[id]/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/database/index.html b/pilot/server/static/database/index.html index f1505512d..a0ea8a3a5 100644 --- a/pilot/server/static/database/index.html +++ b/pilot/server/static/database/index.html @@ -1 +1 @@ -
MySQL

MySQL

Comming soon

Fast, reliable, scalable open-source relational database management system.

MSSQL

MSSQL

Comming soon

Powerful, scalable, secure relational database system by Microsoft.

DuckDB

DuckDB

Comming soon

In-memory analytical database with efficient query processing.

Sqlite

Sqlite

Comming soon

Lightweight embedded relational database with simplicity and portability.

ClickHouse

ClickHouse

Comming soon

Columnar database for high-performance analytics and real-time queries.

Oracle

Oracle

Comming soon

Robust, scalable, secure relational database widely used in enterprises.

Access

Access

Comming soon

Easy-to-use relational database for small-scale applications by Microsoft.

MongoDB

MongoDB

Comming soon

Flexible, scalable NoSQL document database for web and mobile apps.

DB2

DB2

Comming soon

Scalable, secure relational database system developed by IBM.

HBase

HBase

Comming soon

Distributed, scalable NoSQL database for large structured/semi-structured data.

Redis

Redis

Comming soon

Fast, versatile in-memory data structure store as cache, DB, or broker.

Cassandra

Cassandra

Comming soon

Scalable, fault-tolerant distributed NoSQL database for large data.

Couchbase

Couchbase

Comming soon

High-performance NoSQL document database with distributed architecture.

PostgreSQL

PostgreSQL

Comming soon

Powerful open-source relational database with extensibility and SQL standards.

Spark

Spark

Comming soon

Unified engine for large-scale data analytics.

\ No newline at end of file +
MySQL

MySQL

Comming soon

Fast, reliable, scalable open-source relational database management system.

MSSQL

MSSQL

Comming soon

Powerful, scalable, secure relational database system by Microsoft.

DuckDB

DuckDB

Comming soon

In-memory analytical database with efficient query processing.

Sqlite

Sqlite

Comming soon

Lightweight embedded relational database with simplicity and portability.

ClickHouse

ClickHouse

Comming soon

Columnar database for high-performance analytics and real-time queries.

Oracle

Oracle

Comming soon

Robust, scalable, secure relational database widely used in enterprises.

Access

Access

Comming soon

Easy-to-use relational database for small-scale applications by Microsoft.

MongoDB

MongoDB

Comming soon

Flexible, scalable NoSQL document database for web and mobile apps.

DB2

DB2

Comming soon

Scalable, secure relational database system developed by IBM.

HBase

HBase

Comming soon

Distributed, scalable NoSQL database for large structured/semi-structured data.

Redis

Redis

Comming soon

Fast, versatile in-memory data structure store as cache, DB, or broker.

Cassandra

Cassandra

Comming soon

Scalable, fault-tolerant distributed NoSQL database for large data.

Couchbase

Couchbase

Comming soon

High-performance NoSQL document database with distributed architecture.

PostgreSQL

PostgreSQL

Comming soon

Powerful open-source relational database with extensibility and SQL standards.

Spark

Spark

Comming soon

Unified engine for large-scale data analytics.

\ No newline at end of file diff --git a/pilot/server/static/datastores/documents/chunklist/index.html b/pilot/server/static/datastores/documents/chunklist/index.html index bc06022d9..d9575eb9a 100644 --- a/pilot/server/static/datastores/documents/chunklist/index.html +++ b/pilot/server/static/datastores/documents/chunklist/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/datastores/documents/index.html b/pilot/server/static/datastores/documents/index.html index af4cd3fa4..fe8800d72 100644 --- a/pilot/server/static/datastores/documents/index.html +++ b/pilot/server/static/datastores/documents/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/datastores/index.html b/pilot/server/static/datastores/index.html index f92a50391..15a387d96 100644 --- a/pilot/server/static/datastores/index.html +++ b/pilot/server/static/datastores/index.html @@ -1 +1 @@ -
+
space
\ No newline at end of file +
+
space
\ No newline at end of file diff --git a/pilot/server/static/index.html b/pilot/server/static/index.html index 5ea3a90dd..e1378dc6b 100644 --- a/pilot/server/static/index.html +++ b/pilot/server/static/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/models/index.html b/pilot/server/static/models/index.html index 4ed70878c..6fc381fb4 100644 --- a/pilot/server/static/models/index.html +++ b/pilot/server/static/models/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/pilot/server/static/prompt/index.html b/pilot/server/static/prompt/index.html index 8b5b716fe..7f86bcbd0 100644 --- a/pilot/server/static/prompt/index.html +++ b/pilot/server/static/prompt/index.html @@ -1 +1 @@ -
NameSceneSub SceneContentOperation
No data
\ No newline at end of file +
NameSceneSub SceneContentOperation
No data
\ No newline at end of file diff --git a/setup.py b/setup.py index 3785a277d..1876669cf 100644 --- a/setup.py +++ b/setup.py @@ -309,6 +309,7 @@ def core_requires(): "gTTS==2.3.1", "langchain>=0.0.286", "SQLAlchemy==2.0.22", + "fastapi==0.98.0", "pymysql", "duckdb==0.8.1", "duckdb-engine",