Skip to content

Conversation

@WainWong
Copy link

Summary

  • 添加基于 LLM 的表选择功能,优先于 RAG 表嵌入方式
  • LLM 可以更准确地理解用户问题并选择相关表,特别是对于复杂的多表查询场景
  • 支持配置开关,可灵活选择使用 LLM 表选择或 RAG 表嵌入

Changes

  • backend/apps/datasource/llm_select/table_selection.py: 新增 LLM 表选择核心逻辑
  • backend/apps/template/select_table/generator.py: 表选择 prompt 生成器
  • backend/apps/datasource/crud/datasource.py: 集成 LLM 表选择到表 schema 获取流程
  • backend/apps/chat/task/llm.py: 延迟 schema 获取以支持日志记录
  • backend/common/core/config.py: 添加 LLM 表选择配置项
  • backend/alembic/versions/054_add_table_select_answer.py: 数据库迁移脚本

Add a new LLM-based table selection feature that can replace or work alongside
the existing RAG-based table embedding. Key changes:

- New table selection module (backend/apps/datasource/llm_select/)
- New config option TABLE_LLM_SELECTION_ENABLED (default: true)
- Add table_select_answer field to ChatRecord for logging LLM selections
- Add SELECT_TABLE operation type for tracking in chat logs
- Skip foreign key relation table completion when using LLM selection
  (LLM already sees table relations and can decide which tables to include)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant