microsoft / TaskWeaver

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

sql_pull_data plugin is throwing NameError: name 'sql_pull_data' is not defined for gemini-pro #229

Closed rrimmana closed 7 months ago

rrimmana commented 7 months ago

Describe the bug Though code interpreter is generating the code but we see NameError: name 'sql_pull_data' is not defined for gemini-pro llm. Is this supported for gemini-pro model?. Does Taskweaver support function calling https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling Please help in resolving above issue. To Reproduce Steps to reproduce the behavior:

  1. Enabled the sql_data_pull plugin and ask a question. Even its same in UI
  2. See error stack below.


    | | | | | | / / __ | |/ _/ __| |/ /| | /| / / _ \/ __/ | / / _ \/ / | | (| __ \ < | |/ |/ / _/ // /| |/ / / / ||_,_|/|_|/|/_/_,/ |/\/_/

    TaskWeaver ▶ I am TaskWeaver, an AI assistant. To get started, could you please enter your request? Human ▶ pull data from time_series table in database ╭───< Planner > ├─► [init_plan] │ 1. ask the user to provide the database name │ 2. ask the user to provide the query │ 3. instruct CodeInterpreter to pull data from the database │ 4. report the result to the user <interactively depends on 3> ├─► [plan] │ 1. ask the user to provide the database name │ 2. ask the user to provide the query │ 3. instruct CodeInterpreter to pull data from the database │ 4. report the result to the user ├─► [current_plan_step] 1. ask the user to provide the database name ├──● What is the name of the database? ╰──● sending message to User TaskWeaver ▶ What is the name of the database? Human ▶ C:\Taskweaver\TaskWeaver\project\sample_data\anomaly_detection.db ╭───< Planner > ├─► [init_plan] │ 1. ask the user to provide the database name │ 2. ask the user to provide the query │ 3. instruct CodeInterpreter to pull data from the database │ 4. report the result to the user <interactively depends on 3> ├─► [plan] │ 1. ask the user to provide the database name │ 2. ask the user to provide the query │ 3. instruct CodeInterpreter to pull data from the database │ 4. report the result to the user ├─► [current_plan_step] 2. ask the user to provide the query ├──● What is the query to pull data from the database? ╰──● sending message to User TaskWeaver ▶ What is the query to pull data from the database? Human ▶ select from time_series ╭───< Planner > ├─► [init_plan] │ 1. ask the user to provide the database name │ 2. ask the user to provide the query │ 3. instruct CodeInterpreter to pull data from the database │ 4. report the result to the user <interactively depends on 3> ├─► [plan] │ 1. instruct CodeInterpreter to pull data from the database │ 2. report the result to the user ├─► [current_plan_step] 1. instruct CodeInterpreter to pull data from the database ├──● Please pull data from the database using the query: select from time_series ╰──● sending message to CodeInterpreter ╭───< CodeInterpreter > ├─► [thought] ProgramApe will generate a code snippet to pull data from the database using the query: select from time_series. ├─► [python] │ import pandas as pd │ │ query = "select from time_series" │ │ df, description = sql_pull_data(query) │ result = df ├─► [verification] NONE ├─► [code_error] No code verification is performed. Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data cannot import name 'Gemini' from 'langchain.chat_models' (C:\gitlabcode\vertexAI\Taskweaver\TaskWeaver.venv\Lib\site-packages\langchain\chat_models__init__.py) ├─► [execution_status] FAILURE ├─► [execution_result] │ 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 5 │ df, description = sql_pull_data(query) │ │ NameError: name 'sql_pull_data' is not defined │ │ ├─► [artifact_paths] [] ├──● The following python code has been executed: │ python │ import pandas as pd │ │ query = "select * from time_series" │ │ df, description = sql_pull_data(query) │ result = 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 5 │ df, description = sql_pull_data(query) │ │ NameError: name 'sql_pull_data' is not defined │ │ ├─► [revise_message]

Expected behavior A clear and concise description of what you expected to happen. NA if feel not applicable.

Screenshots

image

Environment Information (please complete the following information):

Additional context Will the custom plugins be supported for gemini-pro model.

liqul commented 7 months ago

The error message

Plugin sql_pull_data failed to load: Plugin sql_pull_data failed to register: failed to load plugin sql_pull_data cannot import name 'Gemini' from 'langchain.chat_models' (C:\gitlabcode\vertexAI\Taskweaver\TaskWeaver.venv\Lib\site-packages\langchain\chat_models_init_.py)

is saying that the plugin failed to load successfully. That is why later it is said the name sql_pull_data is not recognized.

I guess you want to use gemini-pro for the sql_pull_data plugin, and I can see you have implemented the logic inside the plugin implementation. But the error suggests that langchain doesn't recognize this name 'Gemini'. So you need to check the actual name of the gemini model in langchain's official documents.

rrimmana commented 7 months ago

Thanks @liqul for quick reply Didn't notice it. Got it working now with. image