{"id":13468902,"url":"https://github.com/vanna-ai/vanna","last_synced_at":"2025-05-13T15:01:55.756Z","repository":{"id":164910842,"uuid":"640317662","full_name":"vanna-ai/vanna","owner":"vanna-ai","description":"🤖 Chat with your SQL database 📊. Accurate Text-to-SQL Generation via LLMs using RAG 🔄.","archived":false,"fork":false,"pushed_at":"2025-04-10T03:18:09.000Z","size":7239,"stargazers_count":17420,"open_issues_count":183,"forks_count":1543,"subscribers_count":125,"default_branch":"main","last_synced_at":"2025-05-06T11:29:07.502Z","etag":null,"topics":["agent","ai","data-visualization","database","llm","rag","sql","text-to-sql"],"latest_commit_sha":null,"homepage":"https://vanna.ai/docs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vanna-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-13T17:26:28.000Z","updated_at":"2025-05-06T11:26:30.000Z","dependencies_parsed_at":"2023-11-13T19:24:58.434Z","dependency_job_id":"ca8d681e-8481-41e4-a513-14e3561ac5f3","html_url":"https://github.com/vanna-ai/vanna","commit_stats":null,"previous_names":["vanna-ai/vanna","vanna-ai/vanna-py"],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanna-ai%2Fvanna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanna-ai%2Fvanna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanna-ai%2Fvanna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanna-ai%2Fvanna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanna-ai","download_url":"https://codeload.github.com/vanna-ai/vanna/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253967861,"owners_count":21992251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","data-visualization","database","llm","rag","sql","text-to-sql"],"created_at":"2024-07-31T15:01:21.576Z","updated_at":"2025-05-13T15:01:55.716Z","avatar_url":"https://github.com/vanna-ai.png","language":"Python","funding_links":[],"categories":["Python","Table of Contents","🔍 RAG とナレッジ","[Vanna.AI](https://vanna.ai/)","Azure Cognitive Search \u0026 OpenAI","Sql Generation","A01_文本生成_文本对话","语言资源库","Tools \u0026 Frameworks","Projects","Industry Strength Information Retrieval","开源工具","Repos","Table of Open-Source AI Agents Projects","Corporate and Analytical Applications","agent","🗃️ SQL \u0026 Databases","\u003ca name=\"Python\"\u003e\u003c/a\u003ePython","Tools","6. RAG Pipelines","RAG / knowledge system","LLM Tools","📦 Legacy \u0026 Inactive Projects","Structured \u0026 SQL RAG","AI 机器学习"],"sub_categories":["LLM Interpretability Tools","その他の標準","Links","大语言对话模型及数据","python","Text2SQL","📋 Others","SQL增强","RAG and Business Analytics","Tools","Retrieval-Augmented Generation","Rust","Frameworks \u0026 Tools"],"readme":"\n\n| GitHub | PyPI | Documentation | Gurubase |\n| ------ | ---- | ------------- | -------- |\n| [![GitHub](https://img.shields.io/badge/GitHub-vanna-blue?logo=github)](https://github.com/vanna-ai/vanna) | [![PyPI](https://img.shields.io/pypi/v/vanna?logo=pypi)](https://pypi.org/project/vanna/) | [![Documentation](https://img.shields.io/badge/Documentation-vanna-blue?logo=read-the-docs)](https://vanna.ai/docs/) | [![Gurubase](https://img.shields.io/badge/Gurubase-Ask%20Vanna%20Guru-006BFF)](https://gurubase.io/g/vanna) |\n\n# Vanna\nVanna is an MIT-licensed open-source Python RAG (Retrieval-Augmented Generation) framework for SQL generation and related functionality.\n\nhttps://github.com/vanna-ai/vanna/assets/7146154/1901f47a-515d-4982-af50-f12761a3b2ce\n\n![vanna-quadrants](https://github.com/vanna-ai/vanna/assets/7146154/1c7c88ba-c144-4ecf-a028-cf5ba7344ca2)\n\n## How Vanna works\n\n![Screen Recording 2024-01-24 at 11 21 37 AM](https://github.com/vanna-ai/vanna/assets/7146154/1d2718ad-12a8-4a76-afa2-c61754462f93)\n\n\nVanna works in two easy steps - train a RAG \"model\" on your data, and then ask questions which will return SQL queries that can be set up to automatically run on your database.\n\n1. **Train a RAG \"model\" on your data**.\n2. **Ask questions**.\n\n![](img/vanna-readme-diagram.png)\n\nIf you don't know what RAG is, don't worry -- you don't need to know how this works under the hood to use it. You just need to know that you \"train\" a model, which stores some metadata and then use it to \"ask\" questions.\n\nSee the [base class](https://github.com/vanna-ai/vanna/blob/main/src/vanna/base/base.py) for more details on how this works under the hood.\n\n## User Interfaces\nThese are some of the user interfaces that we've built using Vanna. You can use these as-is or as a starting point for your own custom interface.\n\n- [Jupyter Notebook](https://vanna.ai/docs/postgres-openai-vanna-vannadb/)\n- [vanna-ai/vanna-streamlit](https://github.com/vanna-ai/vanna-streamlit)\n- [vanna-ai/vanna-flask](https://github.com/vanna-ai/vanna-flask)\n- [vanna-ai/vanna-slack](https://github.com/vanna-ai/vanna-slack)\n\n## Supported LLMs\n\n- [OpenAI](https://github.com/vanna-ai/vanna/tree/main/src/vanna/openai)\n- [Anthropic](https://github.com/vanna-ai/vanna/tree/main/src/vanna/anthropic)\n- [Gemini](https://github.com/vanna-ai/vanna/blob/main/src/vanna/google/gemini_chat.py)\n- [HuggingFace](https://github.com/vanna-ai/vanna/blob/main/src/vanna/hf/hf.py)\n- [AWS Bedrock](https://github.com/vanna-ai/vanna/tree/main/src/vanna/bedrock)\n- [Ollama](https://github.com/vanna-ai/vanna/tree/main/src/vanna/ollama)\n- [Qianwen](https://github.com/vanna-ai/vanna/tree/main/src/vanna/qianwen)\n- [Qianfan](https://github.com/vanna-ai/vanna/tree/main/src/vanna/qianfan)\n- [Zhipu](https://github.com/vanna-ai/vanna/tree/main/src/vanna/ZhipuAI)\n\n## Supported VectorStores\n\n- [AzureSearch](https://github.com/vanna-ai/vanna/tree/main/src/vanna/azuresearch)\n- [Opensearch](https://github.com/vanna-ai/vanna/tree/main/src/vanna/opensearch)\n- [PgVector](https://github.com/vanna-ai/vanna/tree/main/src/vanna/pgvector)\n- [PineCone](https://github.com/vanna-ai/vanna/tree/main/src/vanna/pinecone)\n- [ChromaDB](https://github.com/vanna-ai/vanna/tree/main/src/vanna/chromadb)\n- [FAISS](https://github.com/vanna-ai/vanna/tree/main/src/vanna/faiss)\n- [Marqo](https://github.com/vanna-ai/vanna/tree/main/src/vanna/marqo)\n- [Milvus](https://github.com/vanna-ai/vanna/tree/main/src/vanna/milvus)\n- [Qdrant](https://github.com/vanna-ai/vanna/tree/main/src/vanna/qdrant)\n- [Weaviate](https://github.com/vanna-ai/vanna/tree/main/src/vanna/weaviate)\n- [Oracle](https://github.com/vanna-ai/vanna/tree/main/src/vanna/oracle)\n\n## Supported Databases\n\n- [PostgreSQL](https://www.postgresql.org/)\n- [MySQL](https://www.mysql.com/)\n- [PrestoDB](https://prestodb.io/)\n- [Apache Hive](https://hive.apache.org/)\n- [ClickHouse](https://clickhouse.com/)\n- [Snowflake](https://www.snowflake.com/en/)\n- [Oracle](https://www.oracle.com/)\n- [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)\n- [BigQuery](https://cloud.google.com/bigquery)\n- [SQLite](https://www.sqlite.org/)\n- [DuckDB](https://duckdb.org/)\n\n\n## Getting started\nSee the [documentation](https://vanna.ai/docs/) for specifics on your desired database, LLM, etc.\n\nIf you want to get a feel for how it works after training, you can try this [Colab notebook](https://vanna.ai/docs/app/).\n\n\n### Install\n```bash\npip install vanna\n```\n\nThere are a number of optional packages that can be installed so see the [documentation](https://vanna.ai/docs/) for more details.\n\n### Import\nSee the [documentation](https://vanna.ai/docs/) if you're customizing the LLM or vector database.\n\n```python\n# The import statement will vary depending on your LLM and vector database. This is an example for OpenAI + ChromaDB\n\nfrom vanna.openai.openai_chat import OpenAI_Chat\nfrom vanna.chromadb.chromadb_vector import ChromaDB_VectorStore\n\nclass MyVanna(ChromaDB_VectorStore, OpenAI_Chat):\n    def __init__(self, config=None):\n        ChromaDB_VectorStore.__init__(self, config=config)\n        OpenAI_Chat.__init__(self, config=config)\n\nvn = MyVanna(config={'api_key': 'sk-...', 'model': 'gpt-4-...'})\n\n# See the documentation for other options\n\n```\n\n\n## Training\nYou may or may not need to run these `vn.train` commands depending on your use case. See the [documentation](https://vanna.ai/docs/) for more details.\n\nThese statements are shown to give you a feel for how it works.\n\n### Train with DDL Statements\nDDL statements contain information about the table names, columns, data types, and relationships in your database.\n\n```python\nvn.train(ddl=\"\"\"\n    CREATE TABLE IF NOT EXISTS my-table (\n        id INT PRIMARY KEY,\n        name VARCHAR(100),\n        age INT\n    )\n\"\"\")\n```\n\n### Train with Documentation\nSometimes you may want to add documentation about your business terminology or definitions.\n\n```python\nvn.train(documentation=\"Our business defines XYZ as ...\")\n```\n\n### Train with SQL\nYou can also add SQL queries to your training data. This is useful if you have some queries already laying around. You can just copy and paste those from your editor to begin generating new SQL.\n\n```python\nvn.train(sql=\"SELECT name, age FROM my-table WHERE name = 'John Doe'\")\n```\n\n\n## Asking questions\n```python\nvn.ask(\"What are the top 10 customers by sales?\")\n```\n\nYou'll get SQL\n```sql\nSELECT c.c_name as customer_name,\n        sum(l.l_extendedprice * (1 - l.l_discount)) as total_sales\nFROM   snowflake_sample_data.tpch_sf1.lineitem l join snowflake_sample_data.tpch_sf1.orders o\n        ON l.l_orderkey = o.o_orderkey join snowflake_sample_data.tpch_sf1.customer c\n        ON o.o_custkey = c.c_custkey\nGROUP BY customer_name\nORDER BY total_sales desc limit 10;\n```\n\nIf you've connected to a database, you'll get the table:\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eCUSTOMER_NAME\u003c/th\u003e\n      \u003cth\u003eTOTAL_SALES\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003eCustomer#000143500\u003c/td\u003e\n      \u003ctd\u003e6757566.0218\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003eCustomer#000095257\u003c/td\u003e\n      \u003ctd\u003e6294115.3340\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003eCustomer#000087115\u003c/td\u003e\n      \u003ctd\u003e6184649.5176\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003eCustomer#000131113\u003c/td\u003e\n      \u003ctd\u003e6080943.8305\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003eCustomer#000134380\u003c/td\u003e\n      \u003ctd\u003e6075141.9635\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e5\u003c/th\u003e\n      \u003ctd\u003eCustomer#000103834\u003c/td\u003e\n      \u003ctd\u003e6059770.3232\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e6\u003c/th\u003e\n      \u003ctd\u003eCustomer#000069682\u003c/td\u003e\n      \u003ctd\u003e6057779.0348\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e7\u003c/th\u003e\n      \u003ctd\u003eCustomer#000102022\u003c/td\u003e\n      \u003ctd\u003e6039653.6335\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e8\u003c/th\u003e\n      \u003ctd\u003eCustomer#000098587\u003c/td\u003e\n      \u003ctd\u003e6027021.5855\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e9\u003c/th\u003e\n      \u003ctd\u003eCustomer#000064660\u003c/td\u003e\n      \u003ctd\u003e5905659.6159\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\nYou'll also get an automated Plotly chart:\n![](img/top-10-customers.png)\n\n## RAG vs. Fine-Tuning\nRAG\n- Portable across LLMs\n- Easy to remove training data if any of it becomes obsolete\n- Much cheaper to run than fine-tuning\n- More future-proof -- if a better LLM comes out, you can just swap it out\n\nFine-Tuning\n- Good if you need to minimize tokens in the prompt\n- Slow to get started\n- Expensive to train and run (generally)\n\n## Why Vanna?\n\n1. **High accuracy on complex datasets.**\n    - Vanna’s capabilities are tied to the training data you give it\n    - More training data means better accuracy for large and complex datasets\n2. **Secure and private.**\n    - Your database contents are never sent to the LLM or the vector database\n    - SQL execution happens in your local environment\n3. **Self learning.**\n    - If using via Jupyter, you can choose to \"auto-train\" it on the queries that were successfully executed\n    - If using via other interfaces, you can have the interface prompt the user to provide feedback on the results\n    - Correct question to SQL pairs are stored for future reference and make the future results more accurate\n4. **Supports any SQL database.**\n    - The package allows you to connect to any SQL database that you can otherwise connect to with Python\n5. **Choose your front end.**\n    - Most people start in a Jupyter Notebook.\n    - Expose to your end users via Slackbot, web app, Streamlit app, or a custom front end.\n\n## Extending Vanna\nVanna is designed to connect to any database, LLM, and vector database. There's a [VannaBase](https://github.com/vanna-ai/vanna/blob/main/src/vanna/base/base.py) abstract base class that defines some basic functionality. The package provides implementations for use with OpenAI and ChromaDB. You can easily extend Vanna to use your own LLM or vector database. See the [documentation](https://vanna.ai/docs/) for more details.\n\n## Vanna in 100 Seconds\n\nhttps://github.com/vanna-ai/vanna/assets/7146154/eb90ee1e-aa05-4740-891a-4fc10e611cab\n\n## More resources\n - [Full Documentation](https://vanna.ai/docs/)\n - [Website](https://vanna.ai)\n - [Discord group for support](https://discord.gg/qUZYKHremx)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanna-ai%2Fvanna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanna-ai%2Fvanna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanna-ai%2Fvanna/lists"}