Skip to content

Commit e2221d7

Browse files
committed
Update to common
1 parent b5e2a74 commit e2221d7

File tree

6 files changed

+86
-15
lines changed

6 files changed

+86
-15
lines changed

text_2_sql/autogen/Iteration 5 - Agentic Vector Based Text2SQL.ipynb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 2,
33+
"execution_count": 3,
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
@@ -44,21 +44,20 @@
4444
},
4545
{
4646
"cell_type": "code",
47-
"execution_count": 3,
47+
"execution_count": 4,
4848
"metadata": {},
4949
"outputs": [
5050
{
51-
"ename": "ModuleNotFoundError",
52-
"evalue": "No module named 'utils'",
51+
"ename": "ImportError",
52+
"evalue": "cannot import name 'SqlConnector' from 'text_2_sql_core.connectors.sql' (/workspaces/dstoolkit-text2sql-and-imageprocessing/text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/sql.py)",
5353
"output_type": "error",
5454
"traceback": [
5555
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
56-
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
57-
"Cell \u001b[0;32mIn[3], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mlogging\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_agentchat\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtask\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Console\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AutoGenText2Sql\n",
56+
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
57+
"Cell \u001b[0;32mIn[4], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mlogging\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_agentchat\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtask\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Console\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AutoGenText2Sql\n",
5858
"File \u001b[0;32m/workspaces/dstoolkit-text2sql-and-imageprocessing/text_2_sql/autogen/src/autogen_text_2_sql/autogen_text_2_sql.py:6\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_agentchat\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mteams\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m SelectorGroupChat\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcreators\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mllm_model_creator\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m LLMModelCreator\n\u001b[0;32m----> 6\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcreators\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mllm_agent_creator\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m LLMAgentCreator\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mlogging\u001b[39;00m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_text_2_sql\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcustom_agents\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msql_query_cache_agent\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m SqlQueryCacheAgent\n",
5959
"File \u001b[0;32m/workspaces/dstoolkit-text2sql-and-imageprocessing/text_2_sql/autogen/src/autogen_text_2_sql/creators/llm_agent_creator.py:6\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_core\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcomponents\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtools\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m FunctionTool\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mautogen_agentchat\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01magents\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AssistantAgent\n\u001b[0;32m----> 6\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtext_2_sql_core\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconnectors\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01msql\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m SqlConnector\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mllm_model_creator\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m LLMModelCreator\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mjinja2\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Template\n",
60-
"File \u001b[0;32m/workspaces/dstoolkit-text2sql-and-imageprocessing/text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/sql.py:7\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01maioodbc\u001b[39;00m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtyping\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Annotated, Union\n\u001b[0;32m----> 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mutils\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mai_search\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m AISearchHelper\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mjson\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01masyncio\u001b[39;00m\n",
61-
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'utils'"
60+
"\u001b[0;31mImportError\u001b[0m: cannot import name 'SqlConnector' from 'text_2_sql_core.connectors.sql' (/workspaces/dstoolkit-text2sql-and-imageprocessing/text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/sql.py)"
6261
]
6362
}
6463
],
@@ -81,6 +80,8 @@
8180
"traceback": [
8281
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
8382
"\n",
83+
"\n",
84+
"\n",
8485
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
8586
]
8687
}
@@ -101,6 +102,8 @@
101102
"traceback": [
102103
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
103104
"\n",
105+
"\n",
106+
"\n",
104107
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
105108
]
106109
}
@@ -128,6 +131,8 @@
128131
"traceback": [
129132
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
130133
"\n",
134+
"\n",
135+
"\n",
131136
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
132137
]
133138
}
@@ -148,6 +153,8 @@
148153
"traceback": [
149154
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
150155
"\n",
156+
"\n",
157+
"\n",
151158
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
152159
]
153160
}
@@ -168,6 +175,8 @@
168175
"traceback": [
169176
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
170177
"\n",
178+
"\n",
179+
"\n",
171180
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
172181
]
173182
}
@@ -188,6 +197,8 @@
188197
"traceback": [
189198
"\u001b[1;31mThe kernel failed to start due to the missing module 'pygments.formatters.terminal256'. Consider installing this module.\n",
190199
"\n",
200+
"\n",
201+
"\n",
191202
"\u001b[1;31mClick <a href='https://aka.ms/kernelFailuresMissingModule'>here</a> for more info."
192203
]
193204
}

text_2_sql/autogen/src/autogen_text_2_sql/custom_agents/sql_query_cache_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from autogen_agentchat.base import Response
77
from autogen_agentchat.messages import AgentMessage, ChatMessage, TextMessage
88
from autogen_core.base import CancellationToken
9-
from utils.sql import SqlHelper
9+
from utils.sql import SqlConnector
1010
import json
1111
import logging
1212

@@ -18,7 +18,7 @@ def __init__(self):
1818
"An agent that fetches the queries from the cache based on the user question.",
1919
)
2020

21-
self.sql_helper = SqlHelper()
21+
self.sql_helper = SqlConnector()
2222

2323
@property
2424
def produced_message_types(self) -> List[type[ChatMessage]]:

text_2_sql/text_2_sql_core/pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ requires-python = ">=3.12"
1010
dependencies = [
1111
"aioodbc>=0.5.0",
1212
"azure-identity>=1.19.0",
13+
"azure-search>=1.0.0b2",
14+
"azure-search-documents==11.6.0b8",
15+
"jinja2>=3.1.4",
1316
"networkx>=3.4.2",
1417
"openai>=1.55.3",
1518
"pydantic>=2.10.2",
1619
"python-dotenv>=1.0.1",
20+
"pyyaml>=6.0.2",
21+
"sqlglot[rs]>=25.32.1",
1722
]
1823

1924
[project.optional-dependencies]
@@ -27,3 +32,8 @@ databricks = [
2732
[build-system]
2833
requires = ["hatchling"]
2934
build-backend = "hatchling.build"
35+
36+
[dependency-groups]
37+
dev = [
38+
"python-dotenv>=1.0.1",
39+
]

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/ai_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from datetime import datetime, timezone
1313

1414

15-
class AISearchHelper:
15+
class AISearchConnector:
1616
@staticmethod
1717
async def run_ai_search_query(
1818
query,

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/sql.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import os
55
import aioodbc
66
from typing import Annotated, Union
7-
from text_2_sql_core.connectors.ai_search import AISearchHelper
7+
from text_2_sql_core.connectors.ai_search import AISearchConnector
88
import json
99
import asyncio
1010
import sqlglot
1111

1212

13-
class SqlHelper:
13+
class SqlConnector:
1414
def __init__(self):
1515
self.use_query_cache = (
1616
os.environ.get("Text2Sql__UseQueryCache", "False").lower() == "true"
@@ -41,7 +41,7 @@ async def get_entity_schemas(
4141
str: The schema of the views or tables in JSON format.
4242
"""
4343

44-
schemas = await AISearchHelper.run_ai_search_query(
44+
schemas = await AISearchConnector.run_ai_search_query(
4545
text,
4646
["DefinitionEmbedding"],
4747
[
@@ -130,7 +130,7 @@ async def fetch_queries_from_cache(self, question: str) -> str:
130130
-------
131131
str: The formatted string of the queries fetched from the cache. This is injected into the prompt.
132132
"""
133-
cached_schemas = await AISearchHelper.run_ai_search_query(
133+
cached_schemas = await AISearchConnector.run_ai_search_query(
134134
question,
135135
["QuestionEmbedding"],
136136
["Question", "SqlQueryDecomposition"],

uv.lock

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)