Open problemxl opened 4 months ago
Can you please update your langchain version to latest and try again. That will resolve the issue.
I updated to langchain 0.1.10 and I'm experiencing the same issue.
Same issue , what I would suggest is the usage of agent type.. When I am using gpt3.5 turbo with open ai function on same db .. it is retrieving the results When I am using groq, we canyt use this function and looks like zero shot is not the way forwards
#llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
agent_executor = create_sql_agent(llm, db=db, agent_type="zero-shot-react-description", verbose=True)
Entering new SQL Agent Executor chain... To answer this question, I need to first understand the structure of the "anime_reviwes" table. I will use the "sql_db_schema" tool to get the schema and sample rows of the table.
Action: sql_db_schema Action Input: anime_reviews sql_db_schema is not a valid tool, try one of [sql_db_query, sql_db_schema, sql_db_list_tables, sql_db_query_checker].I made a mistake in using the tool's name. I should use "sql_db_schema" to get the schema of the "anime_reviews" table.
Action: sql_db_schema Action Input: anime_reviews sql_db_schema is not a valid tool, try one of [sql_db_query, sql_db_schema, sql_db_list_tables, sql_db_query_checker].I made a mistake in the tool name, it should be "sql_db_schema". I will try again.
Action: sql_db_schema Action Input: anime_reviews sql_db_schema is not a valid tool, try one of [sql_db_query, sql_db_schema, sql_db_list_tables, sql_db_query_checker].I am facing an issue where the provided tool "sql_db_schema" is not being recognized. I will inform the user about this issue so they can take appropriate action.
Final Answer: It seems there is an issue with the provided tools as "sql_db_schema" is not being recognized. Please check the tool availability or notify the system administrator.
Finished chain. {'input': 'List the top animes in anime_reviwes table ?', 'output': 'It seems there is an issue with the provided tools as "sql\_db\_schema" is not being recognized. Please check the tool availability or notify the system administrator.'}
Did anyone found a solution to this issue?
I updated to langchain 0.1.12 and I'm experiencing the same issue.
Looks mostly to do with Mixtral escaping "" with "_" causing the issue. in my local llama I tried system prompt 'Do not escape "" OR underscores' Works many times not always, may be you can give it a try.
version 0.1.13 same issue here
As a workaround you can make a copy of the SQLDatabaseToolkit and use it with modified names.
copy lib\python\site-package\langchain_community\agen_toolkits\sql\toolkit.py and lib\python\site-package\langchain_community\tools\sql_database\tool.py in workspace.
use tool.py copy in toolkit.py
from tool import (
InfoSQLDatabaseTool,
ListSQLDatabaseTool,
QuerySQLCheckerTool,
QuerySQLDataBaseTool,
)
eg.:
name: str = "sqldbschema" # instead of sql_db_schema
from toolkit import SQLDatabaseToolkit
As a workaround you can make a copy of the SQLDatabaseToolkit and use it with modified names.
- copy lib\python\site-package\langchain_community\agen_toolkits\sql\toolkit.py and lib\python\site-package\langchain_community\tools\sql_database\tool.py in workspace.
- use tool.py copy in toolkit.py
from tool import ( InfoSQLDatabaseTool, ListSQLDatabaseTool, QuerySQLCheckerTool, QuerySQLDataBaseTool, )
- change names of the tool names in tool.py
eg.:
name: str = "sqldbschema" # instead of sql_db_schema
- in your implementation use:
from toolkit import SQLDatabaseToolkit
Thanks, your method works.
Checked other resources
Example Code
The following code:
Error Message and Stack Trace (if applicable)
Description
When attempting to use the SQL Database agent with LLMs that aren't from OpenAI, it produces this loop caused by back slash escape sequences.
I have included groq utilizing the mixtral model but I have also experienced this using ollama, llama.cpp testing a number of different LLM models including but not limited to mixtral, mistral, llama, phi, codellama, etc.
I do not experience this bug when using gpt-3.5-turbo and gpt-4
System Info
langchain: 0.1.9 python: 3.11.3 OS: Windows