vanna 0.5.2__py3-none-any.whl → 0.5.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vanna/base/base.py
CHANGED
|
@@ -1012,6 +1012,85 @@ class VannaBase(ABC):
|
|
|
1012
1012
|
self.run_sql_is_set = True
|
|
1013
1013
|
self.run_sql = run_sql_mysql
|
|
1014
1014
|
|
|
1015
|
+
def connect_to_clickhouse(
|
|
1016
|
+
self,
|
|
1017
|
+
host: str = None,
|
|
1018
|
+
dbname: str = None,
|
|
1019
|
+
user: str = None,
|
|
1020
|
+
password: str = None,
|
|
1021
|
+
port: int = None,
|
|
1022
|
+
):
|
|
1023
|
+
|
|
1024
|
+
try:
|
|
1025
|
+
from clickhouse_driver import connect
|
|
1026
|
+
except ImportError:
|
|
1027
|
+
raise DependencyError(
|
|
1028
|
+
"You need to install required dependencies to execute this method,"
|
|
1029
|
+
" run command: \npip install clickhouse-driver"
|
|
1030
|
+
)
|
|
1031
|
+
|
|
1032
|
+
if not host:
|
|
1033
|
+
host = os.getenv("HOST")
|
|
1034
|
+
|
|
1035
|
+
if not host:
|
|
1036
|
+
raise ImproperlyConfigured("Please set your ClickHouse host")
|
|
1037
|
+
|
|
1038
|
+
if not dbname:
|
|
1039
|
+
dbname = os.getenv("DATABASE")
|
|
1040
|
+
|
|
1041
|
+
if not dbname:
|
|
1042
|
+
raise ImproperlyConfigured("Please set your ClickHouse database")
|
|
1043
|
+
|
|
1044
|
+
if not user:
|
|
1045
|
+
user = os.getenv("USER")
|
|
1046
|
+
|
|
1047
|
+
if not user:
|
|
1048
|
+
raise ImproperlyConfigured("Please set your ClickHouse user")
|
|
1049
|
+
|
|
1050
|
+
if not password:
|
|
1051
|
+
password = os.getenv("PASSWORD")
|
|
1052
|
+
|
|
1053
|
+
if not password:
|
|
1054
|
+
raise ImproperlyConfigured("Please set your ClickHouse password")
|
|
1055
|
+
|
|
1056
|
+
if not port:
|
|
1057
|
+
port = os.getenv("PORT")
|
|
1058
|
+
|
|
1059
|
+
if not port:
|
|
1060
|
+
raise ImproperlyConfigured("Please set your ClickHouse port")
|
|
1061
|
+
|
|
1062
|
+
conn = None
|
|
1063
|
+
|
|
1064
|
+
try:
|
|
1065
|
+
conn = connect(host=host,
|
|
1066
|
+
user=user,
|
|
1067
|
+
password=password,
|
|
1068
|
+
database=dbname,
|
|
1069
|
+
port=port,
|
|
1070
|
+
)
|
|
1071
|
+
print(conn)
|
|
1072
|
+
except Exception as e:
|
|
1073
|
+
raise ValidationError(e)
|
|
1074
|
+
|
|
1075
|
+
def run_sql_clickhouse(sql: str) -> Union[pd.DataFrame, None]:
|
|
1076
|
+
if conn:
|
|
1077
|
+
try:
|
|
1078
|
+
cs = conn.cursor()
|
|
1079
|
+
cs.execute(sql)
|
|
1080
|
+
results = cs.fetchall()
|
|
1081
|
+
|
|
1082
|
+
# Create a pandas dataframe from the results
|
|
1083
|
+
df = pd.DataFrame(
|
|
1084
|
+
results, columns=[desc[0] for desc in cs.description]
|
|
1085
|
+
)
|
|
1086
|
+
return df
|
|
1087
|
+
|
|
1088
|
+
except Exception as e:
|
|
1089
|
+
raise e
|
|
1090
|
+
|
|
1091
|
+
self.run_sql_is_set = True
|
|
1092
|
+
self.run_sql = run_sql_clickhouse
|
|
1093
|
+
|
|
1015
1094
|
def connect_to_oracle(
|
|
1016
1095
|
self,
|
|
1017
1096
|
user: str = None,
|
|
@@ -1372,6 +1451,10 @@ class VannaBase(ABC):
|
|
|
1372
1451
|
def run_sql_presto(sql: str) -> Union[pd.DataFrame, None]:
|
|
1373
1452
|
if conn:
|
|
1374
1453
|
try:
|
|
1454
|
+
sql = sql.rstrip()
|
|
1455
|
+
# fix for a known problem with presto db where an extra ; will cause an error.
|
|
1456
|
+
if sql.endswith(';'):
|
|
1457
|
+
sql = sql[:-1]
|
|
1375
1458
|
cs = conn.cursor()
|
|
1376
1459
|
cs.execute(sql)
|
|
1377
1460
|
results = cs.fetchall()
|
|
@@ -1393,6 +1476,102 @@ class VannaBase(ABC):
|
|
|
1393
1476
|
self.run_sql_is_set = True
|
|
1394
1477
|
self.run_sql = run_sql_presto
|
|
1395
1478
|
|
|
1479
|
+
def connect_to_hive(
|
|
1480
|
+
self,
|
|
1481
|
+
host: str = None,
|
|
1482
|
+
dbname: str = 'default',
|
|
1483
|
+
user: str = None,
|
|
1484
|
+
password: str = None,
|
|
1485
|
+
port: int = None,
|
|
1486
|
+
auth: str = 'CUSTOM'
|
|
1487
|
+
):
|
|
1488
|
+
"""
|
|
1489
|
+
Connect to a Hive database. This is just a helper function to set [`vn.run_sql`][vanna.base.base.VannaBase.run_sql]
|
|
1490
|
+
Connect to a Hive database. This is just a helper function to set [`vn.run_sql`][vanna.base.base.VannaBase.run_sql]
|
|
1491
|
+
|
|
1492
|
+
Args:
|
|
1493
|
+
host (str): The host of the Hive database.
|
|
1494
|
+
dbname (str): The name of the database to connect to.
|
|
1495
|
+
user (str): The username to use for authentication.
|
|
1496
|
+
password (str): The password to use for authentication.
|
|
1497
|
+
port (int): The port to use for the connection.
|
|
1498
|
+
auth (str): The authentication method to use.
|
|
1499
|
+
|
|
1500
|
+
Returns:
|
|
1501
|
+
None
|
|
1502
|
+
"""
|
|
1503
|
+
|
|
1504
|
+
try:
|
|
1505
|
+
from pyhive import hive
|
|
1506
|
+
except ImportError:
|
|
1507
|
+
raise DependencyError(
|
|
1508
|
+
"You need to install required dependencies to execute this method,"
|
|
1509
|
+
" run command: \npip install pyhive"
|
|
1510
|
+
)
|
|
1511
|
+
|
|
1512
|
+
if not host:
|
|
1513
|
+
host = os.getenv("HIVE_HOST")
|
|
1514
|
+
|
|
1515
|
+
if not host:
|
|
1516
|
+
raise ImproperlyConfigured("Please set your hive host")
|
|
1517
|
+
|
|
1518
|
+
if not dbname:
|
|
1519
|
+
dbname = os.getenv("HIVE_DATABASE")
|
|
1520
|
+
|
|
1521
|
+
if not dbname:
|
|
1522
|
+
raise ImproperlyConfigured("Please set your hive database")
|
|
1523
|
+
|
|
1524
|
+
if not user:
|
|
1525
|
+
user = os.getenv("HIVE_USER")
|
|
1526
|
+
|
|
1527
|
+
if not user:
|
|
1528
|
+
raise ImproperlyConfigured("Please set your hive user")
|
|
1529
|
+
|
|
1530
|
+
if not password:
|
|
1531
|
+
password = os.getenv("HIVE_PASSWORD")
|
|
1532
|
+
|
|
1533
|
+
if not port:
|
|
1534
|
+
port = os.getenv("HIVE_PORT")
|
|
1535
|
+
|
|
1536
|
+
if not port:
|
|
1537
|
+
raise ImproperlyConfigured("Please set your hive port")
|
|
1538
|
+
|
|
1539
|
+
conn = None
|
|
1540
|
+
|
|
1541
|
+
try:
|
|
1542
|
+
conn = hive.Connection(host=host,
|
|
1543
|
+
username=user,
|
|
1544
|
+
password=password,
|
|
1545
|
+
database=dbname,
|
|
1546
|
+
port=port,
|
|
1547
|
+
auth=auth)
|
|
1548
|
+
except hive.Error as e:
|
|
1549
|
+
raise ValidationError(e)
|
|
1550
|
+
|
|
1551
|
+
def run_sql_hive(sql: str) -> Union[pd.DataFrame, None]:
|
|
1552
|
+
if conn:
|
|
1553
|
+
try:
|
|
1554
|
+
cs = conn.cursor()
|
|
1555
|
+
cs.execute(sql)
|
|
1556
|
+
results = cs.fetchall()
|
|
1557
|
+
|
|
1558
|
+
# Create a pandas dataframe from the results
|
|
1559
|
+
df = pd.DataFrame(
|
|
1560
|
+
results, columns=[desc[0] for desc in cs.description]
|
|
1561
|
+
)
|
|
1562
|
+
return df
|
|
1563
|
+
|
|
1564
|
+
except hive.Error as e:
|
|
1565
|
+
print(e)
|
|
1566
|
+
raise ValidationError(e)
|
|
1567
|
+
|
|
1568
|
+
except Exception as e:
|
|
1569
|
+
print(e)
|
|
1570
|
+
raise e
|
|
1571
|
+
|
|
1572
|
+
self.run_sql_is_set = True
|
|
1573
|
+
self.run_sql = run_sql_hive
|
|
1574
|
+
|
|
1396
1575
|
def run_sql(self, sql: str, **kwargs) -> pd.DataFrame:
|
|
1397
1576
|
"""
|
|
1398
1577
|
Example:
|
vanna/ollama/ollama.py
CHANGED
|
@@ -24,7 +24,7 @@ class Ollama(VannaBase):
|
|
|
24
24
|
raise ValueError("config must contain at least Ollama model")
|
|
25
25
|
self.host = config.get("ollama_host", "http://localhost:11434")
|
|
26
26
|
self.model = config["model"]
|
|
27
|
-
if ":" in self.model:
|
|
27
|
+
if ":" not in self.model:
|
|
28
28
|
self.model += ":latest"
|
|
29
29
|
|
|
30
30
|
self.ollama_client = ollama.Client(self.host, timeout=Timeout(240.0))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vanna
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: Generate SQL queries from natural language
|
|
5
5
|
Author-email: Zain Hoda <zain@vanna.ai>
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -41,6 +41,7 @@ Requires-Dist: transformers ; extra == "all"
|
|
|
41
41
|
Requires-Dist: anthropic ; extra == "anthropic"
|
|
42
42
|
Requires-Dist: google-cloud-bigquery ; extra == "bigquery"
|
|
43
43
|
Requires-Dist: chromadb ; extra == "chromadb"
|
|
44
|
+
Requires-Dist: clickhouse_driver ; extra == "clickhouse"
|
|
44
45
|
Requires-Dist: duckdb ; extra == "duckdb"
|
|
45
46
|
Requires-Dist: google-generativeai ; extra == "gemini"
|
|
46
47
|
Requires-Dist: google-generativeai ; extra == "google"
|
|
@@ -68,6 +69,7 @@ Provides-Extra: all
|
|
|
68
69
|
Provides-Extra: anthropic
|
|
69
70
|
Provides-Extra: bigquery
|
|
70
71
|
Provides-Extra: chromadb
|
|
72
|
+
Provides-Extra: clickhouse
|
|
71
73
|
Provides-Extra: duckdb
|
|
72
74
|
Provides-Extra: gemini
|
|
73
75
|
Provides-Extra: google
|
|
@@ -8,7 +8,7 @@ vanna/ZhipuAI/__init__.py,sha256=NlsijtcZp5Tj9jkOe9fNcOQND_QsGgu7otODsCLBPr0,116
|
|
|
8
8
|
vanna/anthropic/__init__.py,sha256=85s_2mAyyPxc0T_0JEvYeAkEKWJwkwqoyUwSC5dw9Gk,43
|
|
9
9
|
vanna/anthropic/anthropic_chat.py,sha256=Wk0o-NMW1uvR2fhSWxrR_2FqNh-dLprNG4uuVqpqAkY,2615
|
|
10
10
|
vanna/base/__init__.py,sha256=Sl-HM1RRYzAZoSqmL1CZQmF3ZF-byYTCFQP3JZ2A5MU,28
|
|
11
|
-
vanna/base/base.py,sha256=
|
|
11
|
+
vanna/base/base.py,sha256=uz0M07nln8nJQfuqq17yCSQOEJF9p1tt8CUGltkcPIM,70850
|
|
12
12
|
vanna/chromadb/__init__.py,sha256=-iL0nW_g4uM8nWKMuWnNePfN4nb9uk8P3WzGvezOqRg,50
|
|
13
13
|
vanna/chromadb/chromadb_vector.py,sha256=eKyPck99Y6Jt-BNWojvxLG-zvAERzLSm-3zY-bKXvaA,8792
|
|
14
14
|
vanna/exceptions/__init__.py,sha256=dJ65xxxZh1lqBeg6nz6Tq_r34jLVmjvBvPO9Q6hFaQ8,685
|
|
@@ -24,7 +24,7 @@ vanna/marqo/marqo.py,sha256=W7WTtzWp4RJjZVy6OaXHqncUBIPdI4Q7qH7BRCxZ1_A,5242
|
|
|
24
24
|
vanna/mistral/__init__.py,sha256=70rTY-69Z2ehkkMj84dNMCukPo6AWdflBGvIB_pztS0,29
|
|
25
25
|
vanna/mistral/mistral.py,sha256=DAEqAT9SzC91rfMM_S3SuzBZ34MrKHw9qAj6EP2MGVk,1508
|
|
26
26
|
vanna/ollama/__init__.py,sha256=4xyu8aHPdnEHg5a-QAMwr5o0ns5wevsp_zkI-ndMO2k,27
|
|
27
|
-
vanna/ollama/ollama.py,sha256=
|
|
27
|
+
vanna/ollama/ollama.py,sha256=rXa7cfvdlO1E5SLysXIl3IZpIaA2r0RBvV5jX2-upiE,3794
|
|
28
28
|
vanna/openai/__init__.py,sha256=tGkeQ7wTIPsando7QhoSHehtoQVdYLwFbKNlSmCmNeQ,86
|
|
29
29
|
vanna/openai/openai_chat.py,sha256=lm-hUsQxu6Q1t06A2csC037zI4VkMk0wFbQ-_Lj74Wg,4764
|
|
30
30
|
vanna/openai/openai_embeddings.py,sha256=g4pNh9LVcYP9wOoO8ecaccDFWmCUYMInebfHucAa2Gc,1260
|
|
@@ -37,6 +37,6 @@ vanna/vannadb/__init__.py,sha256=C6UkYocmO6dmzfPKZaWojN0mI5YlZZ9VIbdcquBE58A,48
|
|
|
37
37
|
vanna/vannadb/vannadb_vector.py,sha256=9YwTO3Lh5owWQE7KPMBqLp2EkiGV0RC1sEYhslzJzgI,6168
|
|
38
38
|
vanna/vllm/__init__.py,sha256=aNlUkF9tbURdeXAJ8ytuaaF1gYwcG3ny1MfNl_cwQYg,23
|
|
39
39
|
vanna/vllm/vllm.py,sha256=QerC3xF5eNzE_nGBDl6YrPYF4WYnjf0hHxxlDWdKX-0,2427
|
|
40
|
-
vanna-0.5.
|
|
41
|
-
vanna-0.5.
|
|
42
|
-
vanna-0.5.
|
|
40
|
+
vanna-0.5.4.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
41
|
+
vanna-0.5.4.dist-info/METADATA,sha256=kVa5DQIjYZjgyXwVTKQW-2HjGj54ZzAF7cwYUQiXk60,11332
|
|
42
|
+
vanna-0.5.4.dist-info/RECORD,,
|
|
File without changes
|