Vanna ASk
1 2 3 4 5 6 7 8 9 10 11 12 13
| from src.vanna.ollama import Ollama from src.vanna.chromadb import ChromaDB_VectorStore from src.vanna.flask import VannaFlaskApp
class MyVanna(ChromaDB_VectorStore, Ollama): def __init__(self, config=None): ChromaDB_VectorStore.__init__(self, config=config) Ollama.__init__(self, config=config)
vn = MyVanna(config={'model': 'qwen2.5-coder:32b','ollama_host':'http://172.16.54.149:11434'}) vn.connect_to_mysql(user='root',password='123456',host='172.16.54.161',dbname='eims_test',port=3306) VannaFlaskApp(vn, allow_llm_to_see_data=True).run(port=8085, host='0.0.0.0')
|
由于已经运行过 Vanna train 内对应的训练代码 上述不展示
接下来的问题测试均为 查询下 ys_vehicle_transfer 表中有哪些数据
运行
generate_sql
请求 URL:http://127.0.0.1:8085/api/v0/generate_sql
请求方法:GET
| Key |
Value |
| question |
“question” |
return
1 2 3 4 5
| { "id": "your id", "text": "SELECT * FROM ys_vehicle_transfer;", "type": "sql" }
|
run_sql
请求 URL:http://127.0.0.1:8085/api/v0/run_sql
请求方法:GET
| Key |
Value |
| id |
“id from generate_sql” |
return
1 2 3 4 5
| { "df": "df content", "id": "your id", "type": "df" }
|
download_csv
请求 URL:http://127.0.0.1:8085/api/v0/download_csv
请求方法:GET
| Key |
Value |
| id |
“id from generate_sql” |
return
generate_plotly_code
请求 URL:http://127.0.0.1:8085/api/v0/generate_plotly_figure
请求方法:GET
| Key |
Value |
| id |
“id from generate_sql” |
return
1 2 3 4 5
| { "fig": "{.........}", "id": "your id", "type": "plotly_figure" }
|