Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] text2sql不生效 #5172

Open
doufangyu opened this issue Jan 2, 2025 · 2 comments
Open

[BUG] text2sql不生效 #5172

doufangyu opened this issue Jan 2, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@doufangyu
Copy link

问题描述 / Problem Description
启用了text2sql后提问没有任何请求数据的操作

复现问题的步骤 / Steps to Reproduce
text2sql:
model_name: glm4-chat
use: true
sqlalchemy_connect_str: mysql+pymysql://user:9!12ddddaas@127.0.0.1:3306/monitor
read_only: true
top_k: 50
return_intermediate_steps: true
table_names: ["monitor_domain","monitor_domain_detail","monitor_application"]
table_comments: {"monitor_application":"这是一个应用表,存储了应用的基本信息","monitor_domain":"这是一个域名信息表"}

预期的结果 / Expected Result
描述应该出现的结果 / Describe the expected result.
应该能查询到表信息或请求数据库

实际结果 / Actual Result
描述实际发生的结果 / Describe the actual result.
INFO: 127.0.0.1:59514 - "GET /knowledge_base/list_knowledge_bases HTTP/1.1" 200 OK
2025-01-02 11:36:44,180 httpx 20636 INFO HTTP Request: GET http://127.0.0.1:7861/knowledge_base/list_knowledge_bases "HTTP/1.1 200 OK"
INFO: 127.0.0.1:59528 - "POST /knowledge_base/local_kb/samples/chat/completions HTTP/1.1" 200 OK
2025-01-02 11:36:44,412 httpx 20636 INFO HTTP Request: POST http://127.0.0.1:7861/knowledge_base/local_kb/samples/chat/completions "HTTP/1.1 200 OK"
2025-01-02 11:36:44,524 httpx 20562 INFO HTTP Request: POST http://127.0.0.1:9997/v1/embeddings "HTTP/1.1 200 OK"
2025-01-02 11:36:44,635 httpx 20562 INFO HTTP Request: POST http://127.0.0.1:9997/v1/embeddings "HTTP/1.1 200 OK"
2025-01-02 11:36:45,291 httpx 20562 INFO HTTP Request: POST http://127.0.0.1:9997/v1/embeddings "HTTP/1.1 200 OK"
/root/miniconda3/envs/chatchat/lib/python3.8/site-packages/langchain_core/vectorstores.py:342: UserWarning: No relevant docs were retrieved using the relevance score threshold 2.0
warnings.warn(
2025-01-02 11:36:45,398 httpx 20562 INFO HTTP Request: POST http://127.0.0.1:9997/v1/chat/completions "HTTP/1.1 200 OK"

环境信息 / Environment Information

  • Langchain-Chatchat 版本 / commit 号:0.3.1.3
  • 部署方式(pypi 安装 / 源码部署 / docker 部署): pypi installation
  • 使用的模型推理框架(Xinference / Ollama / OpenAI API 等):Xinference
  • 使用的 LLM 模型(GLM-4-9B / Qwen2-7B-Instruct 等):glm4-chat
  • 使用的 Embedding 模型(bge-large-zh-v1.5 / m3e-base 等): bge-large-zh-v1.5
  • 使用的向量库类型 (faiss / milvus / pg_vector 等): faiss / Vector library used (faiss, milvus, pg_vector, etc.): faiss
  • 操作系统及版本 / Operating system and version: ubuntu
  • Python 版本 / Python version: 3.9
  • 推理使用的硬件(GPU / CPU / MPS / NPU 等) / Inference hardware (GPU / CPU / MPS / NPU, etc.): GPU nvdia A100
  • 其他相关环境信息 / Other relevant environment information:

附加信息 / Additional Information
添加与问题相关的任何其他信息 / Add any other information related to the issue.

@doufangyu doufangyu added the bug Something isn't working label Jan 2, 2025
@doufangyu doufangyu changed the title [BUG] text2sql不生效 / Concise description of the issue [BUG] text2sql不生效 Jan 2, 2025
Copy link

dosubot bot commented Jan 2, 2025

The issue of 'text2sql' not triggering any database requests in Langchain-Chatchat could be due to several reasons. Here are some potential causes and solutions:

  1. Check Configuration 'use': Ensure that the use parameter under text2sql is set to true, which you have already done.

  2. Verify sqlalchemy_connect_str: Double-check the sqlalchemy_connect_str to ensure it is correctly configured. Any errors in the connection string can prevent the system from connecting to the database.

  3. Model Compatibility: The model_name specified might not be suitable for generating SQL queries. Consider testing with different models to see if the issue persists.

  4. Database Connection: Ensure that the database server is running and accessible from the application. Check for any network issues or firewall settings that might block the connection.

  5. Read-Only Mode: Since read_only is set to true, ensure that the queries you are trying to execute are read-only. This setting will prevent any write operations.

  6. Table Names and Comments: Verify that the table_names and table_comments are correctly specified and match the actual database schema. This helps the model understand the database structure better.

  7. Logs and Errors: Check the application logs for any error messages or warnings that might provide more insight into why the requests are not being triggered.

If these steps do not resolve the issue, further investigation into the logs or error messages would be necessary to diagnose the problem.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@doufangyu
Copy link
Author

Entering new AgentExecutor chain...
INFO: 127.0.0.1:51662 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2025-01-03 10:18:02,811 httpx 102261 INFO HTTP Request: POST http://127.0.0.1:7861/v1/chat/completions "HTTP/1.1 200 OK"
2025-01-03 10:18:02,818 httpx 102261 INFO HTTP Request: POST http://127.0.0.1:9997/v1/chat/completions "HTTP/1.1 200 OK"

Thought: The user is asking to view the data in an application table. I need to use the text2sql tool to convert this natural language request into an SQL query.

Action:

{
  "action": "text2sql",
  "action_input": {
    "query": {
      "title": "Query",
      "description": "View the data in the application table.",
      "type": "string"
    }
  }
}
```2025-01-03 10:18:09.267 | ERROR    | chatchat.server.utils:wrap_done:46 - ValidationError: Caught exception: 1 validation error for text2sqlSchema
query
  str type expected (type=type_error.str)
  
  
  text2sql:
  model_name: glm4-chat
  use: true
  sqlalchemy_connect_str: mysql+pymysql://user:password@123.123.123.123:3306/monitor
  read_only: true
  top_k: 50
  return_intermediate_steps: true
  table_names: ["monitor_domain","monitor_domain_detail","monitor_application"]
  table_comments: {"monitor_application":"应用表,存储了应用的基本信息","monitor_domain_detail":"域名解析详情表"}
  
  
  
  如上所展示,配置的数据可以正常连接 但是提问有些问题
  

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant