| ▲ | Show HN: SLayer, a semantic layer maintained by your agent(github.com) | |||||||
| 11 points by yannranchere 4 hours ago | 3 comments | ||||||||
Hello HN! If you want to connect your agent to a database (say, to build a data analyst chatbot or any kind of agentic app) today you have 2 options: an SQL MCP server or a semantic layer. SQL MCP is the easiest path to setup, especially if you also have a .md knowledge base which the agent can update. It gets quite messy quickly though, especially if there's many interactions or DB is large. Generated SQL is hard to review if you want to understand where the numbers came from, and related queries can be hard to align and compare. The natural alternative is a semantic layer, which is an inventory of what data is available/useful (data models) and an interface for querying it using a structured DSL — usually a list of measures, dimensions, filters, with joins etc. handled under the hood. When we needed a semantic layer at Motley for connecting to our customers' data, we first settled on Cube with custom wiring for multi-tenancy and updating the models on the fly. We quickly hit some limitations which led us to realize existing semantic layers just weren't built for the purpose: they're still a part of the BI world where you want an efficient backend for an essentially static set of human-curated dashboards, whereas agents need to iterate their way to the answer, learning in the process. That's when we built the first version of SLayer, which is now open-source. Using either SLayer MCP or CLI, agents (and humans) can: - Explore models, run queries, connect to multiple databases - Edit columns/measures or create new ones - Create custom models from SQL or from a query on other models - Learn from interactions: save and retrieve natural-language memories linked to models, columns or queries, to form a knowledge base Agents evolve the semantic layer, reuse the results of past interactions, and make fewer mistakes going forward. A few more features: - Auto-creation of models from introspecting your DB schema for a warm start - Embeddability — doesn't need a server running - Python client for doing data analysis with dataframes - Schema drift detection and handling - Expressive DSL with compact, natural representations for arbitrarily deep multistage queries, custom aggregations, time shifts, combining metrics from multiple models, and other features that are tricky to get right in raw SQL On the roadmap: access controls, caching, and more. | ||||||||
| ▲ | ZmeiGorynych 2 hours ago | parent | next [-] | |||||||
Hey HN! I'm Egor, one of SLayer's authors. We built SLayer because the traditional semantic layers felt just too clunky for what we were trying to do. Coming in the next release: joint hybrid search on both memories and entities such as columns: retrieve what's directly relevant to your question. Would you like a dbt SL facade to also drive a dashboard off this, or integration with your favorite database? Let us know! | ||||||||
| ▲ | zaeembhanji 4 hours ago | parent | prev [-] | |||||||
feels much closer to how analysts work vs stateless text-to-SQL every query | ||||||||
| ||||||||