-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi,
I'm trying to create a SQL query that would make use of valid column names passed to the RAG via INFORMATION_SCHEMA.COLUMN. However, the obtained query does not mention any real column.
import vanna
from vanna.remote import VannaDefault
from vanna.openai.openai_chat import OpenAI_Chat
from vanna.chromadb.chromadb_vector import ChromaDB_VectorStore
# Globals
PROJECT_ID = "my_gcp_project"
DATASET_ID = "my_dataset"
TABLE_NAME = "my_table"
OPENAI_API_KEY = "sk-xxxxx"
# Class instantiation
class MyVanna(ChromaDB_VectorStore, OpenAI_Chat):
def __init__(self, config=None):
ChromaDB_VectorStore.__init__(self, config=config)
OpenAI_Chat.__init__(self, config=config)
vn = MyVanna(config={'api_key': OPENAI_API_KEY, 'model': 'gpt-4'})
vn.connect_to_bigquery(project_id=PROJECT_ID)
# The below query is working on BigQuery console.
METADATA_QUERY = f"""
SELECT * FROM `{PROJECT_ID}.{DATASET_ID}.INFORMATION_SCHEMA.COLUMNS`
WHERE table_name = {TABLE_NAME}
"""
df_information_schema = vn.run_sql(METADATA_QUERY)
# This will break up the information schema into bite-sized chunks that can be referenced by the LLM
plan = vn.get_training_plan_generic(df_information_schema)
# If you like the plan, then uncomment this and run it to train
vn.train(plan=plan)
vn.ask(question="Where does John Deere live ?")
# Obtained query
"""
SELECT residence
FROM Authors
WHERE name = 'John Deere';
"""
Neither the fields residence or name exist, nor the table Authors
I also get the following error by the way..
Couldn't run sql: exceptions must derive from BaseException
Thanks for your help !
Metadata
Metadata
Assignees
Labels
No labels