经 AI Skill Hub 精选评估,Glancer 获评「推荐使用」。这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 7.5 分,适合有一定技术背景的用户使用。
Glancer是一款开源的AI工具,基于Ruby on Rails engine,提供自然语言数据库查询接口,简化数据分析和可视化。
Glancer 是一款基于 Ruby 开发的开源工具,专注于 installable、business-intelligence、database 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
Glancer是一款开源的AI工具,基于Ruby on Rails engine,提供自然语言数据库查询接口,简化数据分析和可视化。
Glancer 是一款基于 Ruby 开发的开源工具,专注于 installable、business-intelligence、database 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 克隆仓库 git clone https://github.com/ErnaneJ/glancer cd glancer # 查看安装说明 cat README.md # 按 README 完成环境依赖安装后即可使用
# 查看帮助 glancer --help # 基本运行 glancer [options] <input> # 详细使用说明请查阅文档 # https://github.com/ErnaneJ/glancer
# glancer 配置说明 # 查看配置选项 glancer --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export GLANCER_CONFIG="/path/to/config.yml"
<p align="center"> <img src="./.github/assets/glancer-banner.svg" alt="Glancer" width="100%"> </p>
<p align="center"> <strong>Natural language database queries for your Rails app — powered by RAG and LLMs.</strong> </p>
<p align="center"> <a href="https://github.com/ErnaneJ/glancer/actions/workflows/ci.yml"> <img src="https://github.com/ErnaneJ/glancer/actions/workflows/ci.yml/badge.svg" alt="CI"> </a> <a href="https://github.com/ErnaneJ/glancer"> <img src="https://github.com/ErnaneJ/glancer/raw/refs/heads/badge-generator/.github/badges/coverage.svg" alt="Coverage"> </a> <a href="https://rubygems.org/gems/glancer"> <img src="https://badge.fury.io/rb/glancer.svg" alt="Gem Version"> </a> <a href="LICENSE.txt"> <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"> </a> <a href="https://www.ruby-lang.org/en/"> <img src="https://img.shields.io/badge/ruby-%3E%3D%203.3-CC342D" alt="Ruby >= 3.3"> </a> <a href="https://rubyonrails.org/"> <img src="https://img.shields.io/badge/rails-%3E%3D%207.0-CC0000" alt="Rails >= 7.0"> </a> </p>
---
Glancer is a Ruby on Rails engine that mounts a full chat interface inside your app and lets anyone on your team query the database in plain language, no SQL required. You ask a question, Glancer retrieves the relevant schema context, generates a query, validates and executes it safely, then returns the results with a human-readable explanation.
"How many orders were placed in the last 30 days, grouped by status?"
→ SELECT executed, results shown, answer written in plain language.
<p align="center"> <a href="https://github.com/ErnaneJ/glancer/raw/refs/heads/main/.github/assets/demo.mp4"> <img src="./.github/assets/demo.gif" alt="DEMO"> </a> </p>
| Dependency | Minimum version |
|---|---|
| Ruby | 3.3 |
| Rails | 7.0 |
| Database | SQLite, PostgreSQL, or MySQL / MariaDB |
| LLM provider | Gemini, OpenAI, or OpenRouter API key |
Glancer is built on top of ruby_llm, a provider-agnostic LLM client for Ruby. All LLM calls (query generation, humanized responses, embeddings, and optional question enrichment) go through ruby_llm, so any model it supports works with Glancer.
rails generate glancer:install
This creates:
config/initializers/glancer.rb — your main configuration fileconfig/glancer/llm_context.glancer.md — optional domain context written in Markdown/glancer in config/routes.rbYou can call Glancer's internals directly from the Rails console or your own code:
```ruby
Edit config/initializers/glancer.rb. Minimal working setup:
Glancer.configure do |config|
config.llm_provider = :gemini
config.llm_model = "gemini-2.0-flash"
config.gemini_api_key = ENV["GEMINI_API_KEY"]
config.schema_permission = true # allow indexing db/schema.rb
end
| Option | Default | Description |
|---|---|---|
adapter | auto-detected | :postgres, :mysql, :mysql2, or :sqlite |
query_mode | :sql | :sql (raw SELECT) or :activerecord (Ruby expression) |
read_only_db | nil | Replica connection URL |
statement_timeout | 30.seconds | Max execution time; enforced server-side on PG and MySQL |
llm_provider | :gemini | Default provider for all roles (:gemini, :openai, :openrouter) |
llm_model | "gemini-2.0-flash" | Default model for all roles |
code_provider / code_model | inherits default | Provider/model for query generation |
chat_provider / chat_model | inherits default | Provider/model for humanized responses |
embedding_provider / embedding_model | inherits default | Provider/model for embeddings |
enrichment_provider / enrichment_model | inherits default | Provider/model for question enrichment |
query_enrichment_enabled | false | Pre-retrieval question rewriting to inject table hints |
gemini_api_key | nil | Gemini API key |
openai_api_key | nil | OpenAI API key |
openrouter_api_key | nil | OpenRouter API key |
schema_permission | false | Index db/schema.rb |
models_permission | false | Index app/models/**/*.rb |
context_file_path | "config/glancer/llm_context.glancer.md" | Custom domain context file |
chunk_size | 1000 | Max characters per embedding chunk |
chunk_overlap | 150 | Overlap between consecutive chunks |
k | 5 | Top-k chunks retrieved per question |
min_score | 0.6 | Minimum cosine similarity score (0.0–1.0) |
schema_documents_weight | 1.3 | Score boost for schema chunks |
context_documents_weight | 1.2 | Score boost for context chunks |
models_documents_weight | 1.1 | Score boost for model chunks |
history_limit | 6 | Prior conversation turns included in the LLM prompt |
workflow_cache_ttl | 5.minutes | In-memory result cache TTL; 0 to disable |
log_verbosity | :info | :silent, :none, :info, or :debug |
log_output_path | nil | Log file path; nil writes to stdout |
blazer_path | nil | Blazer base path; auto-detected when blazer gem is present |
Visit /glancer in your browser.
@table_name to pin a specific table to your question; it renders as a chip linked to the schema viewer./glancer/settings./glancer/db-schema.Glancer::Workflow::SQLValidator.validate_tables_exist!("SELECT * FROM orders JOIN unknown_table") ```
result = Glancer::Workflow.run(chat.id, "Which products have never been ordered?")
http://localhost:3000/glancer
chunks = Glancer::Retriever.search("monthly revenue by region")
Glancer 是一个专为 Rails 应用设计的自然语言数据库查询工具。它利用 RAG(检索增强生成)技术与 LLM(大语言模型)的力量,让开发者和用户能够直接通过自然语言与数据库进行交互,无需编写复杂的 SQL 语句即可获取数据洞察。
使用 Glancer 需要满足以下环境要求:Ruby 版本需在 3.3 及以上,Rails 版本需在 7.0 及以上;数据库支持 SQLite、PostgreSQL 或 MySQL/MariaDB;此外,您需要准备 Gemini、OpenAI 或 OpenRouter 的 API key 以驱动 LLM 能力。
安装过程非常简单。首先通过 Gem 安装依赖,然后运行 `rails generate glancer:install` 生成器。该命令会自动创建配置文件 `config/initializers/glancer.rb` 和可选的领域上下文文件 `config/glancer/llm_context.glancer.md`,并自动在 `config/routes.rb` 中挂载 `/glancer` 路由。
Glancer 不仅提供 Web 界面,还支持在 Ruby 代码中直接调用其内部逻辑。您可以在 Rails console 或业务代码中直接调用 Glancer 的 API,例如使用 `Glancer::Retriever` 进行语义搜索,或通过 `Glancer::Workflow.run` 执行完整的自然语言查询流水线。
您可以通过编辑 `config/initializers/glancer.rb` 进行详细配置。支持设置 `llm_provider`(如 :gemini)、`llm_model` 以及相应的 API key。为了安全起见,建议开启 `schema_permission` 以允许索引 `db/schema.rb`。此外,还支持配置 `read_only_db` 以连接只读副本,并设置 `statement_timeout` 防止长查询耗尽资源。
Glancer 提供了一个直观的 Chat 界面,可通过浏览器访问 `/glancer` 使用。该界面支持异步处理机制,消息在后台线程中运行,UI 会通过轮询机制实时反馈进度。界面会通过 Step labels 清晰展示当前流水线状态,包括数据富化、上下文检索及代码生成等步骤。
Glancer 内部构建了一套完整的 Workflow 流水线。通过 `Glancer::Workflow` 模块,您可以运行完整的查询链路;同时内置了 `SQLValidator` 模块,能够根据索引的 Schema 自动校验 SQL 语句中的表引用是否合法,确保生成的查询安全且准确。
安装完成后,您只需访问 `http://localhost:3000/glancer` 即可开始通过自然语言向数据库提问。Glancer 会自动处理从问题理解到结果生成的全过程,让数据查询变得像聊天一样简单。
Glancer是一款开源的AI工具,提供自然语言数据库查询接口,简化数据分析和可视化,值得关注。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
AI Skill Hub 点评:Glancer 的核心功能完整,质量良好。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | glancer |
| 原始描述 | 开源AI工具:A Ruby on Rails engine that adds a natural language database query interface to 。⭐8 · Ruby |
| Topics | installablebusiness-intelligencedatabasegemllmragruby |
| GitHub | https://github.com/ErnaneJ/glancer |
| License | MIT |
| 语言 | Ruby |
收录时间:2026-05-24 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。