vanna 0.7.9__py3-none-any.whl → 2.0.0rc1__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/__init__.py +167 -395
- vanna/agents/__init__.py +7 -0
- vanna/capabilities/__init__.py +17 -0
- vanna/capabilities/agent_memory/__init__.py +21 -0
- vanna/capabilities/agent_memory/base.py +103 -0
- vanna/capabilities/agent_memory/models.py +53 -0
- vanna/capabilities/file_system/__init__.py +14 -0
- vanna/capabilities/file_system/base.py +71 -0
- vanna/capabilities/file_system/models.py +25 -0
- vanna/capabilities/sql_runner/__init__.py +13 -0
- vanna/capabilities/sql_runner/base.py +37 -0
- vanna/capabilities/sql_runner/models.py +13 -0
- vanna/components/__init__.py +92 -0
- vanna/components/base.py +11 -0
- vanna/components/rich/__init__.py +83 -0
- vanna/components/rich/containers/__init__.py +7 -0
- vanna/components/rich/containers/card.py +20 -0
- vanna/components/rich/data/__init__.py +9 -0
- vanna/components/rich/data/chart.py +17 -0
- vanna/components/rich/data/dataframe.py +93 -0
- vanna/components/rich/feedback/__init__.py +21 -0
- vanna/components/rich/feedback/badge.py +16 -0
- vanna/components/rich/feedback/icon_text.py +14 -0
- vanna/components/rich/feedback/log_viewer.py +41 -0
- vanna/components/rich/feedback/notification.py +19 -0
- vanna/components/rich/feedback/progress.py +37 -0
- vanna/components/rich/feedback/status_card.py +28 -0
- vanna/components/rich/feedback/status_indicator.py +14 -0
- vanna/components/rich/interactive/__init__.py +21 -0
- vanna/components/rich/interactive/button.py +95 -0
- vanna/components/rich/interactive/task_list.py +58 -0
- vanna/components/rich/interactive/ui_state.py +93 -0
- vanna/components/rich/specialized/__init__.py +7 -0
- vanna/components/rich/specialized/artifact.py +20 -0
- vanna/components/rich/text.py +16 -0
- vanna/components/simple/__init__.py +15 -0
- vanna/components/simple/image.py +15 -0
- vanna/components/simple/link.py +15 -0
- vanna/components/simple/text.py +11 -0
- vanna/core/__init__.py +193 -0
- vanna/core/_compat.py +19 -0
- vanna/core/agent/__init__.py +10 -0
- vanna/core/agent/agent.py +1407 -0
- vanna/core/agent/config.py +123 -0
- vanna/core/audit/__init__.py +28 -0
- vanna/core/audit/base.py +299 -0
- vanna/core/audit/models.py +131 -0
- vanna/core/component_manager.py +329 -0
- vanna/core/components.py +53 -0
- vanna/core/enhancer/__init__.py +11 -0
- vanna/core/enhancer/base.py +94 -0
- vanna/core/enhancer/default.py +118 -0
- vanna/core/enricher/__init__.py +10 -0
- vanna/core/enricher/base.py +59 -0
- vanna/core/errors.py +47 -0
- vanna/core/evaluation/__init__.py +81 -0
- vanna/core/evaluation/base.py +186 -0
- vanna/core/evaluation/dataset.py +254 -0
- vanna/core/evaluation/evaluators.py +376 -0
- vanna/core/evaluation/report.py +289 -0
- vanna/core/evaluation/runner.py +313 -0
- vanna/core/filter/__init__.py +10 -0
- vanna/core/filter/base.py +67 -0
- vanna/core/lifecycle/__init__.py +10 -0
- vanna/core/lifecycle/base.py +83 -0
- vanna/core/llm/__init__.py +16 -0
- vanna/core/llm/base.py +40 -0
- vanna/core/llm/models.py +61 -0
- vanna/core/middleware/__init__.py +10 -0
- vanna/core/middleware/base.py +69 -0
- vanna/core/observability/__init__.py +11 -0
- vanna/core/observability/base.py +88 -0
- vanna/core/observability/models.py +47 -0
- vanna/core/recovery/__init__.py +11 -0
- vanna/core/recovery/base.py +84 -0
- vanna/core/recovery/models.py +32 -0
- vanna/core/registry.py +278 -0
- vanna/core/rich_component.py +156 -0
- vanna/core/simple_component.py +27 -0
- vanna/core/storage/__init__.py +14 -0
- vanna/core/storage/base.py +46 -0
- vanna/core/storage/models.py +46 -0
- vanna/core/system_prompt/__init__.py +13 -0
- vanna/core/system_prompt/base.py +36 -0
- vanna/core/system_prompt/default.py +157 -0
- vanna/core/tool/__init__.py +18 -0
- vanna/core/tool/base.py +70 -0
- vanna/core/tool/models.py +84 -0
- vanna/core/user/__init__.py +17 -0
- vanna/core/user/base.py +29 -0
- vanna/core/user/models.py +25 -0
- vanna/core/user/request_context.py +70 -0
- vanna/core/user/resolver.py +42 -0
- vanna/core/validation.py +164 -0
- vanna/core/workflow/__init__.py +12 -0
- vanna/core/workflow/base.py +254 -0
- vanna/core/workflow/default.py +789 -0
- vanna/examples/__init__.py +1 -0
- vanna/examples/__main__.py +44 -0
- vanna/examples/anthropic_quickstart.py +80 -0
- vanna/examples/artifact_example.py +293 -0
- vanna/examples/claude_sqlite_example.py +236 -0
- vanna/examples/coding_agent_example.py +300 -0
- vanna/examples/custom_system_prompt_example.py +174 -0
- vanna/examples/default_workflow_handler_example.py +208 -0
- vanna/examples/email_auth_example.py +340 -0
- vanna/examples/evaluation_example.py +269 -0
- vanna/examples/extensibility_example.py +262 -0
- vanna/examples/minimal_example.py +67 -0
- vanna/examples/mock_auth_example.py +227 -0
- vanna/examples/mock_custom_tool.py +311 -0
- vanna/examples/mock_quickstart.py +79 -0
- vanna/examples/mock_quota_example.py +145 -0
- vanna/examples/mock_rich_components_demo.py +396 -0
- vanna/examples/mock_sqlite_example.py +223 -0
- vanna/examples/openai_quickstart.py +83 -0
- vanna/examples/primitive_components_demo.py +305 -0
- vanna/examples/quota_lifecycle_example.py +139 -0
- vanna/examples/visualization_example.py +251 -0
- vanna/integrations/__init__.py +17 -0
- vanna/integrations/anthropic/__init__.py +9 -0
- vanna/integrations/anthropic/llm.py +270 -0
- vanna/integrations/azureopenai/__init__.py +9 -0
- vanna/integrations/azureopenai/llm.py +329 -0
- vanna/integrations/azuresearch/__init__.py +7 -0
- vanna/integrations/azuresearch/agent_memory.py +413 -0
- vanna/integrations/bigquery/__init__.py +5 -0
- vanna/integrations/bigquery/sql_runner.py +81 -0
- vanna/integrations/chromadb/__init__.py +104 -0
- vanna/integrations/chromadb/agent_memory.py +416 -0
- vanna/integrations/clickhouse/__init__.py +5 -0
- vanna/integrations/clickhouse/sql_runner.py +82 -0
- vanna/integrations/duckdb/__init__.py +5 -0
- vanna/integrations/duckdb/sql_runner.py +65 -0
- vanna/integrations/faiss/__init__.py +7 -0
- vanna/integrations/faiss/agent_memory.py +431 -0
- vanna/integrations/google/__init__.py +9 -0
- vanna/integrations/google/gemini.py +370 -0
- vanna/integrations/hive/__init__.py +5 -0
- vanna/integrations/hive/sql_runner.py +87 -0
- vanna/integrations/local/__init__.py +17 -0
- vanna/integrations/local/agent_memory/__init__.py +7 -0
- vanna/integrations/local/agent_memory/in_memory.py +285 -0
- vanna/integrations/local/audit.py +59 -0
- vanna/integrations/local/file_system.py +242 -0
- vanna/integrations/local/file_system_conversation_store.py +255 -0
- vanna/integrations/local/storage.py +62 -0
- vanna/integrations/marqo/__init__.py +7 -0
- vanna/integrations/marqo/agent_memory.py +354 -0
- vanna/integrations/milvus/__init__.py +7 -0
- vanna/integrations/milvus/agent_memory.py +458 -0
- vanna/integrations/mock/__init__.py +9 -0
- vanna/integrations/mock/llm.py +65 -0
- vanna/integrations/mssql/__init__.py +5 -0
- vanna/integrations/mssql/sql_runner.py +66 -0
- vanna/integrations/mysql/__init__.py +5 -0
- vanna/integrations/mysql/sql_runner.py +92 -0
- vanna/integrations/ollama/__init__.py +7 -0
- vanna/integrations/ollama/llm.py +252 -0
- vanna/integrations/openai/__init__.py +10 -0
- vanna/integrations/openai/llm.py +267 -0
- vanna/integrations/openai/responses.py +163 -0
- vanna/integrations/opensearch/__init__.py +7 -0
- vanna/integrations/opensearch/agent_memory.py +411 -0
- vanna/integrations/oracle/__init__.py +5 -0
- vanna/integrations/oracle/sql_runner.py +75 -0
- vanna/integrations/pinecone/__init__.py +7 -0
- vanna/integrations/pinecone/agent_memory.py +329 -0
- vanna/integrations/plotly/__init__.py +5 -0
- vanna/integrations/plotly/chart_generator.py +313 -0
- vanna/integrations/postgres/__init__.py +9 -0
- vanna/integrations/postgres/sql_runner.py +112 -0
- vanna/integrations/premium/agent_memory/__init__.py +7 -0
- vanna/integrations/premium/agent_memory/premium.py +186 -0
- vanna/integrations/presto/__init__.py +5 -0
- vanna/integrations/presto/sql_runner.py +107 -0
- vanna/integrations/qdrant/__init__.py +7 -0
- vanna/integrations/qdrant/agent_memory.py +439 -0
- vanna/integrations/snowflake/__init__.py +5 -0
- vanna/integrations/snowflake/sql_runner.py +147 -0
- vanna/integrations/sqlite/__init__.py +9 -0
- vanna/integrations/sqlite/sql_runner.py +65 -0
- vanna/integrations/weaviate/__init__.py +7 -0
- vanna/integrations/weaviate/agent_memory.py +428 -0
- vanna/{ZhipuAI → legacy/ZhipuAI}/ZhipuAI_embeddings.py +11 -11
- vanna/legacy/__init__.py +403 -0
- vanna/legacy/adapter.py +463 -0
- vanna/{advanced → legacy/advanced}/__init__.py +3 -1
- vanna/{anthropic → legacy/anthropic}/anthropic_chat.py +9 -7
- vanna/{azuresearch → legacy/azuresearch}/azuresearch_vector.py +79 -41
- vanna/{base → legacy/base}/base.py +224 -217
- vanna/legacy/bedrock/__init__.py +1 -0
- vanna/{bedrock → legacy/bedrock}/bedrock_converse.py +13 -12
- vanna/{chromadb → legacy/chromadb}/chromadb_vector.py +3 -1
- vanna/legacy/cohere/__init__.py +2 -0
- vanna/{cohere → legacy/cohere}/cohere_chat.py +19 -14
- vanna/{cohere → legacy/cohere}/cohere_embeddings.py +25 -19
- vanna/{deepseek → legacy/deepseek}/deepseek_chat.py +5 -6
- vanna/legacy/faiss/__init__.py +1 -0
- vanna/{faiss → legacy/faiss}/faiss.py +113 -59
- vanna/{flask → legacy/flask}/__init__.py +84 -43
- vanna/{flask → legacy/flask}/assets.py +5 -5
- vanna/{flask → legacy/flask}/auth.py +5 -4
- vanna/{google → legacy/google}/bigquery_vector.py +75 -42
- vanna/{google → legacy/google}/gemini_chat.py +7 -3
- vanna/{hf → legacy/hf}/hf.py +0 -1
- vanna/{milvus → legacy/milvus}/milvus_vector.py +58 -35
- vanna/{mock → legacy/mock}/llm.py +0 -1
- vanna/legacy/mock/vectordb.py +67 -0
- vanna/legacy/ollama/ollama.py +110 -0
- vanna/{openai → legacy/openai}/openai_chat.py +2 -6
- vanna/legacy/opensearch/opensearch_vector.py +369 -0
- vanna/legacy/opensearch/opensearch_vector_semantic.py +200 -0
- vanna/legacy/oracle/oracle_vector.py +584 -0
- vanna/{pgvector → legacy/pgvector}/pgvector.py +42 -13
- vanna/{qdrant → legacy/qdrant}/qdrant.py +2 -6
- vanna/legacy/qianfan/Qianfan_Chat.py +170 -0
- vanna/legacy/qianfan/Qianfan_embeddings.py +36 -0
- vanna/legacy/qianwen/QianwenAI_chat.py +132 -0
- vanna/{remote.py → legacy/remote.py} +28 -26
- vanna/{utils.py → legacy/utils.py} +6 -11
- vanna/{vannadb → legacy/vannadb}/vannadb_vector.py +115 -46
- vanna/{vllm → legacy/vllm}/vllm.py +5 -6
- vanna/{weaviate → legacy/weaviate}/weaviate_vector.py +59 -40
- vanna/{xinference → legacy/xinference}/xinference.py +6 -6
- vanna/py.typed +0 -0
- vanna/servers/__init__.py +16 -0
- vanna/servers/__main__.py +8 -0
- vanna/servers/base/__init__.py +18 -0
- vanna/servers/base/chat_handler.py +65 -0
- vanna/servers/base/models.py +111 -0
- vanna/servers/base/rich_chat_handler.py +141 -0
- vanna/servers/base/templates.py +331 -0
- vanna/servers/cli/__init__.py +7 -0
- vanna/servers/cli/server_runner.py +204 -0
- vanna/servers/fastapi/__init__.py +7 -0
- vanna/servers/fastapi/app.py +163 -0
- vanna/servers/fastapi/routes.py +183 -0
- vanna/servers/flask/__init__.py +7 -0
- vanna/servers/flask/app.py +132 -0
- vanna/servers/flask/routes.py +137 -0
- vanna/tools/__init__.py +41 -0
- vanna/tools/agent_memory.py +322 -0
- vanna/tools/file_system.py +879 -0
- vanna/tools/python.py +222 -0
- vanna/tools/run_sql.py +165 -0
- vanna/tools/visualize_data.py +195 -0
- vanna/utils/__init__.py +0 -0
- vanna/web_components/__init__.py +44 -0
- vanna-2.0.0rc1.dist-info/METADATA +868 -0
- vanna-2.0.0rc1.dist-info/RECORD +289 -0
- vanna-2.0.0rc1.dist-info/entry_points.txt +3 -0
- vanna/bedrock/__init__.py +0 -1
- vanna/cohere/__init__.py +0 -2
- vanna/faiss/__init__.py +0 -1
- vanna/mock/vectordb.py +0 -55
- vanna/ollama/ollama.py +0 -103
- vanna/opensearch/opensearch_vector.py +0 -392
- vanna/opensearch/opensearch_vector_semantic.py +0 -175
- vanna/oracle/oracle_vector.py +0 -585
- vanna/qianfan/Qianfan_Chat.py +0 -165
- vanna/qianfan/Qianfan_embeddings.py +0 -36
- vanna/qianwen/QianwenAI_chat.py +0 -133
- vanna-0.7.9.dist-info/METADATA +0 -408
- vanna-0.7.9.dist-info/RECORD +0 -79
- /vanna/{ZhipuAI → legacy/ZhipuAI}/ZhipuAI_Chat.py +0 -0
- /vanna/{ZhipuAI → legacy/ZhipuAI}/__init__.py +0 -0
- /vanna/{anthropic → legacy/anthropic}/__init__.py +0 -0
- /vanna/{azuresearch → legacy/azuresearch}/__init__.py +0 -0
- /vanna/{base → legacy/base}/__init__.py +0 -0
- /vanna/{chromadb → legacy/chromadb}/__init__.py +0 -0
- /vanna/{deepseek → legacy/deepseek}/__init__.py +0 -0
- /vanna/{exceptions → legacy/exceptions}/__init__.py +0 -0
- /vanna/{google → legacy/google}/__init__.py +0 -0
- /vanna/{hf → legacy/hf}/__init__.py +0 -0
- /vanna/{local.py → legacy/local.py} +0 -0
- /vanna/{marqo → legacy/marqo}/__init__.py +0 -0
- /vanna/{marqo → legacy/marqo}/marqo.py +0 -0
- /vanna/{milvus → legacy/milvus}/__init__.py +0 -0
- /vanna/{mistral → legacy/mistral}/__init__.py +0 -0
- /vanna/{mistral → legacy/mistral}/mistral.py +0 -0
- /vanna/{mock → legacy/mock}/__init__.py +0 -0
- /vanna/{mock → legacy/mock}/embedding.py +0 -0
- /vanna/{ollama → legacy/ollama}/__init__.py +0 -0
- /vanna/{openai → legacy/openai}/__init__.py +0 -0
- /vanna/{openai → legacy/openai}/openai_embeddings.py +0 -0
- /vanna/{opensearch → legacy/opensearch}/__init__.py +0 -0
- /vanna/{oracle → legacy/oracle}/__init__.py +0 -0
- /vanna/{pgvector → legacy/pgvector}/__init__.py +0 -0
- /vanna/{pinecone → legacy/pinecone}/__init__.py +0 -0
- /vanna/{pinecone → legacy/pinecone}/pinecone_vector.py +0 -0
- /vanna/{qdrant → legacy/qdrant}/__init__.py +0 -0
- /vanna/{qianfan → legacy/qianfan}/__init__.py +0 -0
- /vanna/{qianwen → legacy/qianwen}/QianwenAI_embeddings.py +0 -0
- /vanna/{qianwen → legacy/qianwen}/__init__.py +0 -0
- /vanna/{types → legacy/types}/__init__.py +0 -0
- /vanna/{vannadb → legacy/vannadb}/__init__.py +0 -0
- /vanna/{vllm → legacy/vllm}/__init__.py +0 -0
- /vanna/{weaviate → legacy/weaviate}/__init__.py +0 -0
- /vanna/{xinference → legacy/xinference}/__init__.py +0 -0
- {vanna-0.7.9.dist-info → vanna-2.0.0rc1.dist-info}/WHEEL +0 -0
- {vanna-0.7.9.dist-info → vanna-2.0.0rc1.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,16 +7,16 @@ from azure.core.credentials import AzureKeyCredential
|
|
|
7
7
|
from azure.search.documents import SearchClient
|
|
8
8
|
from azure.search.documents.indexes import SearchIndexClient
|
|
9
9
|
from azure.search.documents.indexes.models import (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
ExhaustiveKnnAlgorithmConfiguration,
|
|
11
|
+
ExhaustiveKnnParameters,
|
|
12
|
+
SearchableField,
|
|
13
|
+
SearchField,
|
|
14
|
+
SearchFieldDataType,
|
|
15
|
+
SearchIndex,
|
|
16
|
+
VectorSearch,
|
|
17
|
+
VectorSearchAlgorithmKind,
|
|
18
|
+
VectorSearchAlgorithmMetric,
|
|
19
|
+
VectorSearchProfile,
|
|
20
20
|
)
|
|
21
21
|
from azure.search.documents.models import VectorFilterMode, VectorizedQuery
|
|
22
22
|
from fastembed import TextEmbedding
|
|
@@ -44,6 +44,7 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
44
44
|
Raises:
|
|
45
45
|
ValueError: If config is None, or if 'azure_search_api_key' is not provided in the config.
|
|
46
46
|
"""
|
|
47
|
+
|
|
47
48
|
def __init__(self, config=None):
|
|
48
49
|
VannaBase.__init__(self, config=config)
|
|
49
50
|
|
|
@@ -54,7 +55,9 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
54
55
|
"config is required, pass an API key, 'azure_search_api_key', in the config."
|
|
55
56
|
)
|
|
56
57
|
|
|
57
|
-
azure_search_endpoint = config.get(
|
|
58
|
+
azure_search_endpoint = config.get(
|
|
59
|
+
"azure_search_endpoint", "https://azcognetive.search.windows.net"
|
|
60
|
+
)
|
|
58
61
|
azure_search_api_key = config.get("azure_search_api_key")
|
|
59
62
|
|
|
60
63
|
self.dimensions = config.get("dimensions", 384)
|
|
@@ -64,22 +67,24 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
64
67
|
|
|
65
68
|
self.n_results_ddl = config.get("n_results_ddl", config.get("n_results", 10))
|
|
66
69
|
self.n_results_sql = config.get("n_results_sql", config.get("n_results", 10))
|
|
67
|
-
self.n_results_documentation = config.get(
|
|
70
|
+
self.n_results_documentation = config.get(
|
|
71
|
+
"n_results_documentation", config.get("n_results", 10)
|
|
72
|
+
)
|
|
68
73
|
|
|
69
74
|
if not azure_search_api_key:
|
|
70
75
|
raise ValueError(
|
|
71
76
|
"'azure_search_api_key' is required in config to use AzureAISearch_VectorStore"
|
|
72
|
-
|
|
77
|
+
)
|
|
73
78
|
|
|
74
79
|
self.index_client = SearchIndexClient(
|
|
75
80
|
endpoint=azure_search_endpoint,
|
|
76
|
-
credential=AzureKeyCredential(azure_search_api_key)
|
|
81
|
+
credential=AzureKeyCredential(azure_search_api_key),
|
|
77
82
|
)
|
|
78
83
|
|
|
79
84
|
self.search_client = SearchClient(
|
|
80
85
|
endpoint=azure_search_endpoint,
|
|
81
86
|
index_name=self.index_name,
|
|
82
|
-
credential=AzureKeyCredential(azure_search_api_key)
|
|
87
|
+
credential=AzureKeyCredential(azure_search_api_key),
|
|
83
88
|
)
|
|
84
89
|
|
|
85
90
|
if self.index_name not in self._get_indexes():
|
|
@@ -87,10 +92,28 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
87
92
|
|
|
88
93
|
def _create_index(self) -> bool:
|
|
89
94
|
fields = [
|
|
90
|
-
SearchableField(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
SearchableField(
|
|
96
|
+
name="id", type=SearchFieldDataType.String, key=True, filterable=True
|
|
97
|
+
),
|
|
98
|
+
SearchableField(
|
|
99
|
+
name="document",
|
|
100
|
+
type=SearchFieldDataType.String,
|
|
101
|
+
searchable=True,
|
|
102
|
+
filterable=True,
|
|
103
|
+
),
|
|
104
|
+
SearchField(
|
|
105
|
+
name="type",
|
|
106
|
+
type=SearchFieldDataType.String,
|
|
107
|
+
filterable=True,
|
|
108
|
+
searchable=True,
|
|
109
|
+
),
|
|
110
|
+
SearchField(
|
|
111
|
+
name="document_vector",
|
|
112
|
+
type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
|
|
113
|
+
searchable=True,
|
|
114
|
+
vector_search_dimensions=self.dimensions,
|
|
115
|
+
vector_search_profile_name="ExhaustiveKnnProfile",
|
|
116
|
+
),
|
|
94
117
|
]
|
|
95
118
|
|
|
96
119
|
vector_search = VectorSearch(
|
|
@@ -100,7 +123,7 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
100
123
|
kind=VectorSearchAlgorithmKind.EXHAUSTIVE_KNN,
|
|
101
124
|
parameters=ExhaustiveKnnParameters(
|
|
102
125
|
metric=VectorSearchAlgorithmMetric.COSINE
|
|
103
|
-
)
|
|
126
|
+
),
|
|
104
127
|
)
|
|
105
128
|
],
|
|
106
129
|
profiles=[
|
|
@@ -108,12 +131,14 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
108
131
|
name="ExhaustiveKnnProfile",
|
|
109
132
|
algorithm_configuration_name="ExhaustiveKnn",
|
|
110
133
|
)
|
|
111
|
-
]
|
|
134
|
+
],
|
|
112
135
|
)
|
|
113
136
|
|
|
114
|
-
index = SearchIndex(
|
|
137
|
+
index = SearchIndex(
|
|
138
|
+
name=self.index_name, fields=fields, vector_search=vector_search
|
|
139
|
+
)
|
|
115
140
|
result = self.index_client.create_or_update_index(index)
|
|
116
|
-
print(f
|
|
141
|
+
print(f"{result.name} created")
|
|
117
142
|
|
|
118
143
|
def _get_indexes(self) -> list:
|
|
119
144
|
return [index for index in self.index_client.list_index_names()]
|
|
@@ -124,7 +149,7 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
124
149
|
"id": id,
|
|
125
150
|
"document": ddl,
|
|
126
151
|
"type": "ddl",
|
|
127
|
-
"document_vector": self.generate_embedding(ddl)
|
|
152
|
+
"document_vector": self.generate_embedding(ddl),
|
|
128
153
|
}
|
|
129
154
|
self.search_client.upload_documents(documents=[document])
|
|
130
155
|
return id
|
|
@@ -135,32 +160,36 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
135
160
|
"id": id,
|
|
136
161
|
"document": doc,
|
|
137
162
|
"type": "doc",
|
|
138
|
-
"document_vector": self.generate_embedding(doc)
|
|
163
|
+
"document_vector": self.generate_embedding(doc),
|
|
139
164
|
}
|
|
140
165
|
self.search_client.upload_documents(documents=[document])
|
|
141
166
|
return id
|
|
142
167
|
|
|
143
168
|
def add_question_sql(self, question: str, sql: str) -> str:
|
|
144
|
-
question_sql_json = json.dumps(
|
|
169
|
+
question_sql_json = json.dumps(
|
|
170
|
+
{"question": question, "sql": sql}, ensure_ascii=False
|
|
171
|
+
)
|
|
145
172
|
id = deterministic_uuid(question_sql_json) + "-sql"
|
|
146
173
|
document = {
|
|
147
174
|
"id": id,
|
|
148
175
|
"document": question_sql_json,
|
|
149
176
|
"type": "sql",
|
|
150
|
-
"document_vector": self.generate_embedding(question_sql_json)
|
|
177
|
+
"document_vector": self.generate_embedding(question_sql_json),
|
|
151
178
|
}
|
|
152
179
|
self.search_client.upload_documents(documents=[document])
|
|
153
180
|
return id
|
|
154
181
|
|
|
155
182
|
def get_related_ddl(self, text: str) -> List[str]:
|
|
156
183
|
result = []
|
|
157
|
-
vector_query = VectorizedQuery(
|
|
184
|
+
vector_query = VectorizedQuery(
|
|
185
|
+
vector=self.generate_embedding(text), fields="document_vector"
|
|
186
|
+
)
|
|
158
187
|
df = pd.DataFrame(
|
|
159
188
|
self.search_client.search(
|
|
160
189
|
top=self.n_results_ddl,
|
|
161
190
|
vector_queries=[vector_query],
|
|
162
191
|
select=["id", "document", "type"],
|
|
163
|
-
filter=f"type eq 'ddl'"
|
|
192
|
+
filter=f"type eq 'ddl'",
|
|
164
193
|
)
|
|
165
194
|
)
|
|
166
195
|
|
|
@@ -170,7 +199,9 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
170
199
|
|
|
171
200
|
def get_related_documentation(self, text: str) -> List[str]:
|
|
172
201
|
result = []
|
|
173
|
-
vector_query = VectorizedQuery(
|
|
202
|
+
vector_query = VectorizedQuery(
|
|
203
|
+
vector=self.generate_embedding(text), fields="document_vector"
|
|
204
|
+
)
|
|
174
205
|
|
|
175
206
|
df = pd.DataFrame(
|
|
176
207
|
self.search_client.search(
|
|
@@ -178,7 +209,7 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
178
209
|
vector_queries=[vector_query],
|
|
179
210
|
select=["id", "document", "type"],
|
|
180
211
|
filter=f"type eq 'doc'",
|
|
181
|
-
vector_filter_mode=VectorFilterMode.PRE_FILTER
|
|
212
|
+
vector_filter_mode=VectorFilterMode.PRE_FILTER,
|
|
182
213
|
)
|
|
183
214
|
)
|
|
184
215
|
|
|
@@ -189,42 +220,49 @@ class AzureAISearch_VectorStore(VannaBase):
|
|
|
189
220
|
def get_similar_question_sql(self, question: str) -> List[str]:
|
|
190
221
|
result = []
|
|
191
222
|
# Vectorize the text
|
|
192
|
-
vector_query = VectorizedQuery(
|
|
223
|
+
vector_query = VectorizedQuery(
|
|
224
|
+
vector=self.generate_embedding(question), fields="document_vector"
|
|
225
|
+
)
|
|
193
226
|
df = pd.DataFrame(
|
|
194
227
|
self.search_client.search(
|
|
195
228
|
top=self.n_results_sql,
|
|
196
229
|
vector_queries=[vector_query],
|
|
197
230
|
select=["id", "document", "type"],
|
|
198
|
-
filter=f"type eq 'sql'"
|
|
231
|
+
filter=f"type eq 'sql'",
|
|
199
232
|
)
|
|
200
233
|
)
|
|
201
234
|
|
|
202
|
-
if len(df):
|
|
235
|
+
if len(df): # Check if there is similar query and the result is not empty
|
|
203
236
|
result = [ast.literal_eval(element) for element in df["document"].tolist()]
|
|
204
237
|
|
|
205
238
|
return result
|
|
206
239
|
|
|
207
240
|
def get_training_data(self) -> List[str]:
|
|
208
|
-
|
|
209
241
|
search = self.search_client.search(
|
|
210
242
|
search_text="*",
|
|
211
|
-
select=[
|
|
212
|
-
filter=f"(type eq 'sql') or (type eq 'ddl') or (type eq 'doc')"
|
|
243
|
+
select=["id", "document", "type"],
|
|
244
|
+
filter=f"(type eq 'sql') or (type eq 'ddl') or (type eq 'doc')",
|
|
213
245
|
).by_page()
|
|
214
246
|
|
|
215
247
|
df = pd.DataFrame([item for page in search for item in page])
|
|
216
248
|
|
|
217
249
|
if len(df):
|
|
218
|
-
df.loc[df["type"] == "sql", "question"] = df.loc[df["type"] == "sql"][
|
|
219
|
-
|
|
220
|
-
|
|
250
|
+
df.loc[df["type"] == "sql", "question"] = df.loc[df["type"] == "sql"][
|
|
251
|
+
"document"
|
|
252
|
+
].apply(lambda x: json.loads(x)["question"])
|
|
253
|
+
df.loc[df["type"] == "sql", "content"] = df.loc[df["type"] == "sql"][
|
|
254
|
+
"document"
|
|
255
|
+
].apply(lambda x: json.loads(x)["sql"])
|
|
256
|
+
df.loc[df["type"] != "sql", "content"] = df.loc[df["type"] != "sql"][
|
|
257
|
+
"document"
|
|
258
|
+
]
|
|
221
259
|
|
|
222
260
|
return df[["id", "question", "content", "type"]]
|
|
223
261
|
|
|
224
262
|
return pd.DataFrame()
|
|
225
263
|
|
|
226
264
|
def remove_training_data(self, id: str) -> bool:
|
|
227
|
-
result = self.search_client.delete_documents(documents=[{
|
|
265
|
+
result = self.search_client.delete_documents(documents=[{"id": id}])
|
|
228
266
|
return result[0].succeeded
|
|
229
267
|
|
|
230
268
|
def remove_index(self):
|