You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3、plugin file: sql_pull_mysql_data.py
import pandas as pd
from taskweaver.plugin import Plugin, register_plugin
import pymysql
@register_plugin
class SqlPullMysqlData(Plugin):
#class SqlPullMysqlData():
def call(self, query: str):
query = "查询产业工人项目列表"
#sql = "select * from opi_project"
sql = "select id as 编码,project_name as 项目名称,area as 项目所在地区, eng_status as 项目状态 from opi_project"
result = query_data(sql)
print(result)
1、Docker host operating system:ubuntun 22.04 desktop
2、Run TaskWeaver using the All-in-One Docker Image:
sudo docker run -it
--name taskweaver
--privileged
--net=host
-e "LLM_API_KEY=sk-0f67XXXX"
-e "LLM_API_TYPE=qwen"
-e "LLM_MODEL=qwen-max"
-e "TASKWEAVER_UID=0"
-e "TASKWEAVER_GID=0"
-p 8000:8000
-v /data/workspace/vscode/vscodeProjects/taskWeaverFromContaner/project:/app/project
--entrypoint /app/entrypoint_chainlit.sh
taskweavercontainers/taskweaver-all-in-one:latest
3、plugin file: sql_pull_mysql_data.py
import pandas as pd
from taskweaver.plugin import Plugin, register_plugin
import pymysql
@register_plugin
class SqlPullMysqlData(Plugin):
#class SqlPullMysqlData():
def call(self, query: str):
query = "查询产业工人项目列表"
#sql = "select * from opi_project"
sql = "select id as 编码,project_name as 项目名称,area as 项目所在地区, eng_status as 项目状态 from opi_project"
result = query_data(sql)
print(result)
"""
常用模块:读写MySQL
"""
def get_conn():
omit some codes
def query_data(sql):
omit some codes
4、plugin file: sql_pull_mysql_data.yaml
name: sql_pull_mysql_data
code: sql_pull_mysql_data
enabled: true
required: true
description: >-
获取产业工人项目数据。
当向用户的答复涉及本插件时,请以中文答复。
不需要把用户输入的自然语言转换为数据库SQL。
以Markdown表格形式展示给用户。
(omit some descriptions)
examples: |-
df, description = sql_pull_mysql_data("从数据库查询产业工人项目列表")
parameters:
type: str
required: true
description: >-
直接把query传入数据库处理,不需要数据库名称、查询条件。
returns:
type: pandas.DataFrame
description: This is the dataframe containing the data from the database.从数据库返回的产业工人项目结果数据。
type: str
description: This is a string describing the data pulled from the database.对从数据库返回的产业工人项目数据的描述。
5、Installing pymysql in the Docker container
docker exec -it taskweaver /bin/bash
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config list
pip install pymysql
6、When asking “显示产业工人项目”,Taskweaver execute the plugin sql_pull_mysql_data, then the backend execption logs:
2024-04-16 15:08:06 - LLM output: {"response": [{"type": "init_plan", "content": "1. 使用sql_pull_mysql_data插件获取产业工人项目数据"}, {"type": "plan", "content": "1. 使用sql_pull_mysql_data插件获取产业工人项目数据"}, {"type": "current_plan_step", "content": "1. 使用sql_pull_mysql_data插件获取产业工人项目数据"}, {"type": "send_to", "content": "sql_pull_mysql_data"}, {"type": "message", "content": "请使用插件功能获取产业工人项目数据"}], "execute_code": true}
2024-04-16 15:08:06 - Planner talk to sql_pull_mysql_data: 请使用插件功能获取产业工人项目数据
2024-04-16 15:08:06 - Traceback (most recent call last):
File "/app/playground/UI/../../taskweaver/session/session.py", line 194, in _send_text_message
post = _send_message(post.send_to, post)
File "/app/playground/UI/../../taskweaver/module/tracing.py", line 174, in wrapper
return func(*args, **kwargs)
File "/app/playground/UI/../../taskweaver/session/session.py", line 182, in _send_message
raise Exception(f"Unknown recipient {recipient}")
Exception: Unknown recipient sql_pull_mysql_data
The text was updated successfully, but these errors were encountered: