microsoft / TaskWeaver

A code-first agent framework for seamlessly planning and executing data analytics tasks.
https://microsoft.github.io/TaskWeaver/
MIT License
5.38k stars 689 forks source link

Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data No module named 'langchain' #288

Closed uebhh closed 7 months ago

uebhh commented 7 months ago

Describe the bug

When I attempted to use the [sql_pull_data] plugin, I encountered an error. I have installed langchain, but I’m unsure of the reason for the issue.

Environment Information (please complete the following information): OS: Windows Python Version: 3.11.8 LLM being used: glm-4 (also tried gpt-4, encountered the same problem)

Additional context

2024-04-08 14:00:55 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 14:01:05 - LLM output: {"response": [{"type": "init_plan", "content": "1. confirm the database access\n2. pull data from the time_series table <sequentially depends on 1>\n3. show the schema of the pulled data <interactively depends on 2>"}, {"type": "plan", "content": "1. confirm the database access and pull data from the time_series table\n2. show the schema of the pulled data"}, {"type": "current_plan_step", "content": "1. confirm the database access and pull data from the time_series table"}, {"type": "send_to", "content": "CodeInterpreter"}, {"type": "message", "content": "Please confirm if we can access the database and pull data from the time_series table"}]} 2024-04-08 14:01:05 - Planner talk to CodeInterpreter: Please confirm if we can access the database and pull data from the time_series table 2024-04-08 14:01:07 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 14:01:12 - LLM output: {"response": [{"type": "thought", "content": "ProgramApe understands that the user wants to confirm the ability to access the database and pull data from the time_series table."}, {"type": "text", "content": "Yes, we can access the database and pull data from the time_series table using the sql_pull_data plugin function."}]} 2024-04-08 14:01:12 - CodeInterpreter talk to Planner: Yes, we can access the database and pull data from the time_series table using the sql_pull_data plugin function. 2024-04-08 14:01:14 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 14:01:24 - LLM output: {"response": [{"type": "init_plan", "content": "1. confirm the database access\n2. pull data from the time_series table <sequentially depends on 1>\n3. show the schema of the pulled data <interactively depends on 2>"}, {"type": "plan", "content": "1. confirm the database access and pull data from the time_series table\n2. show the schema of the pulled data"}, {"type": "current_plan_step", "content": "2. show the schema of the pulled data"}, {"type": "send_to", "content": "CodeInterpreter"}, {"type": "message", "content": "Please pull data from the time_series table and show its schema"}]} 2024-04-08 14:01:24 - Planner talk to CodeInterpreter: Please pull data from the time_series table and show its schema 2024-04-08 14:01:26 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 14:01:30 - LLM output: {"response": [{"type": "python", "content": "df, description = sql_pull_data('pull data from time_series table')\nprint(description)\nprint(df.head())\nprint(df.dtypes)\n"}]} 2024-04-08 14:01:30 - Code to be verified: df, description = sql_pull_data('pull data from time_series table') print(description) print(df.head()) print(df.dtypes)

2024-04-08 14:01:30 - Code to be executed: df, description = sql_pull_data('pull data from time_series table') print(description) print(df.head()) print(df.dtypes)

2024-04-08 14:01:33 - Container is running and connection file is ready. Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data No module named 'langchain' 2024-04-08 14:01:39 - CodeInterpreter talk to CodeInterpreter: The following python code has been executed:

df, description = sql_pull_data('pull data from time_series table')
print(description)
print(df.head())
print(df.dtypes)

The execution of the generated python code above has failed

During execution, the following messages were logged: Traceback (most recent call last):

Cell In[1], line 1 df, description = sql_pull_data('pull data from time_series table')

NameError: name 'sql_pull_data' is not defined

liqul commented 7 months ago

You can see this log Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data No module named 'langchain' saying you don't have langchain installed.

uebhh commented 7 months ago

You can see this log Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data No module named 'langchain' saying you don't have langchain installed.

I have already installed the langchain module, but I keep encountering this exception. I will add a complete set of operational steps, please take a moment to confirm.

Additional context: (taskweaver) d:\TaskWeaver\playground\UI>pip show langchain Name: langchain Version: 0.1.14 Summary: Building applications with LLMs through composability Home-page: https://github.com/langchain-ai/langchain Author: Author-email: License: MIT Location: D:\software\anaconda\envs\taskweaver\Lib\site-packages Requires: aiohttp, dataclasses-json, jsonpatch, langchain-community, langchain-core, langchain-text-splitters, langsmith, numpy, pydantic, PyYAML, requests, SQLAlchemy, tenacity Required-by:

(taskweaver) d:\TaskWeaver\playground\UI>chainlit run app.py If UI is not started, please go to the folder playground/UI and run chainlit run app.py to start the UI 2024-04-08 15:21:48 - Your app is available at http://localhost:8000 2024-04-08 15:21:50 - Session 20240408-072150-f94e1c63 is initialized 2024-04-08 15:21:50 - CodeGenerator initialized successfully 2024-04-08 15:21:50 - Environment local is created. 2024-04-08 15:21:50 - CodeInterpreter initialized successfully. 2024-04-08 15:21:50 - Planner initialized successfully Starting new session 2024-04-08 15:21:50 - Translation file for zh-CN not found. Using default translation en-US. 2024-04-08 15:21:50 - Session 20240408-072150-a1640566 is initialized 2024-04-08 15:21:50 - CodeGenerator initialized successfully 2024-04-08 15:21:50 - CodeInterpreter initialized successfully. 2024-04-08 15:21:50 - Planner initialized successfully Starting new session 2024-04-08 15:21:50 - Translated markdown file for zh-CN not found. Defaulting to chainlit.md. 2024-04-08 15:21:51 - Session 20240408-072151-9fc0b78c is initialized 2024-04-08 15:21:51 - CodeGenerator initialized successfully 2024-04-08 15:21:51 - CodeInterpreter initialized successfully. 2024-04-08 15:21:51 - Planner initialized successfully Starting new session 2024-04-08 15:21:51 - Session 20240408-072151-76409a4d is initialized 2024-04-08 15:21:51 - CodeGenerator initialized successfully 2024-04-08 15:21:51 - CodeInterpreter initialized successfully. 2024-04-08 15:21:51 - Planner initialized successfully Starting new session 2024-04-08 15:21:52 - Session 20240408-072152-2184cf16 is initialized 2024-04-08 15:21:52 - CodeGenerator initialized successfully 2024-04-08 15:21:52 - CodeInterpreter initialized successfully. 2024-04-08 15:21:52 - Planner initialized successfully Starting new session 2024-04-08 15:21:52 - Session 20240408-072152-35b2ed35 is initialized 2024-04-08 15:21:52 - CodeGenerator initialized successfully 2024-04-08 15:21:52 - CodeInterpreter initialized successfully. 2024-04-08 15:21:52 - Planner initialized successfully Starting new session 2024-04-08 15:21:53 - Session 20240408-072153-d0a99b8c is initialized 2024-04-08 15:21:53 - CodeGenerator initialized successfully 2024-04-08 15:21:53 - CodeInterpreter initialized successfully. 2024-04-08 15:21:53 - Planner initialized successfully Starting new session 2024-04-08 15:22:01 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 15:22:13 - LLM output: {"response": [{"type": "init_plan", "content": "1. confirm the database and table name\n2. pull data from the database <sequentially depends on 1>\n3. show the schema of the pulled data <interactively depends on 2>"}, {"type": "plan", "content": "1. confirm the database and table name, then pull data from the database\n2. show the schema of the pulled data"}, {"type": "current_plan_step", "content": "1. confirm the database and table name, then pull data from the database"}, {"type": "send_to", "content": "CodeInterpreter"}, {"type": "message", "content": "Please confirm if the table 'time_series' is in the intended database and then pull the data from it"}]} 2024-04-08 15:22:13 - Planner talk to CodeInterpreter: Please confirm if the table 'time_series' is in the intended database and then pull the data from it 2024-04-08 15:22:15 - HTTP Request: POST https://open.bigmodel.cn/api/paas/v4/chat/completions "HTTP/1.1 200 " 2024-04-08 15:22:21 - LLM output: {"response": [{"type": "thought", "content": "ProgramApe will use the sql_pull_data plugin to confirm the existence of the 'time_series' table and pull the data from it."}, {"type": "python", "content": "df, description = sql_pull_data(\"confirm 'time_series' table and pull data\")\ndf"}]} 2024-04-08 15:22:21 - Code to be verified: df, description = sql_pull_data("confirm 'time_series' table and pull data") df 2024-04-08 15:22:21 - Code to be executed: df, description = sql_pull_data("confirm 'time_series' table and pull data") df 2024-04-08 15:22:23 - Container is running and connection file is ready. Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data No module named 'langchain' 2024-04-08 15:22:29 - CodeInterpreter talk to CodeInterpreter: The following python code has been executed:

df, description = sql_pull_data("confirm 'time_series' table and pull data")
df

The execution of the generated python code above has failed

During execution, the following messages were logged: Traceback (most recent call last):

Cell In[1], line 1 df, description = sql_pull_data("confirm 'time_series' table and pull data")

NameError: name 'sql_pull_data' is not defined

liqul commented 7 months ago

I assume you are using the container mode? check this doc here https://microsoft.github.io/TaskWeaver/docs/code_execution.

uebhh commented 7 months ago

I assume you are using the container mode? check this doc here https://microsoft.github.io/TaskWeaver/docs/code_execution.

After setting it to local model, I can continue the execution. Thank you very much!