Skip to content

Commit 750d940

Browse files
committed
Update relative path
1 parent e2221d7 commit 750d940

File tree

8 files changed

+212
-114
lines changed

8 files changed

+212
-114
lines changed

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

Lines changed: 184 additions & 97 deletions
Large diffs are not rendered by default.

text_2_sql/autogen/src/autogen_text_2_sql/creators/llm_agent_creator.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
3-
import yaml
43
from autogen_core.components.tools import FunctionTool
54
from autogen_agentchat.agents import AssistantAgent
65
from text_2_sql_core.connectors.sql import SqlConnector
7-
from llm_model_creator import LLMModelCreator
6+
from text_2_sql_core.prompts.load import load
7+
from autogen_text_2_sql.creators.llm_model_creator import LLMModelCreator
88
from jinja2 import Template
99
from datetime import datetime
1010

@@ -21,10 +21,8 @@ def load_agent_file(cls, name: str) -> dict:
2121
Returns:
2222
-------
2323
dict: The agent file."""
24-
with open(f"./agents/llm_agents/{name.lower()}.yaml", "r") as file:
25-
file = yaml.safe_load(file)
2624

27-
return file
25+
return load(name.lower())
2826

2927
@classmethod
3028
def get_tool(cls, sql_helper: SqlConnector, tool_name: str):

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

Lines changed: 1 addition & 1 deletion
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 SqlConnector
9+
from text_2_sql_core.connectors.sql import SqlConnector
1010
import json
1111
import logging
1212

text_2_sql/semantic_kernel/Iteration 2 - Prompt Based Text2SQL.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
")\n",
7272
"from semantic_kernel.contents.chat_history import ChatHistory\n",
7373
"from semantic_kernel.kernel import Kernel\n",
74-
"from plugins.prompt_based_sql_plugin.prompt_based_sql_plugin import PromptBasedSQLPlugin\n",
74+
"from semantic_kernel_text_2_sql.plugins.prompt_based_sql_plugin.prompt_based_sql_plugin import PromptBasedSQLPlugin\n",
7575
"from semantic_kernel.functions.kernel_arguments import KernelArguments\n",
7676
"from semantic_kernel.prompt_template.prompt_template_config import PromptTemplateConfig\n",
7777
"from IPython.display import display, Markdown\n",
@@ -208,7 +208,7 @@
208208
"outputs": [],
209209
"source": [
210210
"# Load prompt and execution settings from the file\n",
211-
"with open(\"./prompt.yaml\", \"r\") as file:\n",
211+
"with open(\"./semantic_kernel_text_2_sql/src/prompt.yaml\", \"r\") as file:\n",
212212
" data = yaml.safe_load(file.read())\n",
213213
" prompt_template_config = PromptTemplateConfig(**data)"
214214
]

text_2_sql/semantic_kernel/Iterations 3 & 4 - Vector Based Text2SQL.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
")\n",
7272
"from semantic_kernel.contents.chat_history import ChatHistory\n",
7373
"from semantic_kernel.kernel import Kernel\n",
74-
"from plugins.vector_based_sql_plugin.vector_based_sql_plugin import VectorBasedSQLPlugin\n",
74+
"from semantic_kernel_text_2_sql.plugins.vector_based_sql_plugin.vector_based_sql_plugin import VectorBasedSQLPlugin\n",
7575
"from semantic_kernel.functions.kernel_arguments import KernelArguments\n",
7676
"from semantic_kernel.prompt_template.prompt_template_config import PromptTemplateConfig\n",
7777
"from IPython.display import display, Markdown\n",
@@ -196,7 +196,7 @@
196196
"outputs": [],
197197
"source": [
198198
"# Load prompt and execution settings from the file\n",
199-
"with open(\"./prompt.yaml\", \"r\") as file:\n",
199+
"with open(\"./semantic_kernel_text_2_sql/src/prompt.yaml\", \"r\") as file:\n",
200200
" data = yaml.safe_load(file.read())\n",
201201
" prompt_template_config = PromptTemplateConfig(**data)"
202202
]

text_2_sql/semantic_kernel/src/semantic_kernel_text_2_sql/plugins/vector_based_sql_plugin/vector_based_sql_plugin.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import os
66
import json
77
import logging
8-
from utils.ai_search import (
9-
add_entry_to_index,
10-
run_ai_search_query,
11-
)
8+
from text_2_sql_core.connectors.ai_search import AISearchConnector
129
import asyncio
1310
import aioodbc
1411

@@ -36,6 +33,8 @@ def __init__(self, target_engine: str = "Microsoft TSQL Server"):
3633

3734
self.set_mode()
3835

36+
self.ai_search = AISearchConnector()
37+
3938
def set_mode(self):
4039
"""Set the mode of the plugin based on the environment variables."""
4140
self.use_query_cache = (
@@ -111,7 +110,7 @@ async def fetch_schemas_from_store(self, search: str) -> list[dict]:
111110
Returns:
112111
-------
113112
list[dict]: The list of schemas fetched from the store."""
114-
schemas = await run_ai_search_query(
113+
schemas = await self.ai_search.run_ai_search_query(
115114
search,
116115
["DefinitionEmbedding"],
117116
[
@@ -150,7 +149,7 @@ async def fetch_queries_from_cache(self, question: str) -> str:
150149
if not self.use_query_cache:
151150
return None
152151

153-
cached_schemas = await run_ai_search_query(
152+
cached_schemas = await self.ai_search.run_ai_search_query(
154153
question,
155154
["QuestionEmbedding"],
156155
["Question", "SqlQueryDecomposition"],
@@ -362,7 +361,7 @@ async def run_sql_query(
362361
raise e
363362
else:
364363
if entry is not None:
365-
task = add_entry_to_index(
364+
task = self.ai_search.add_entry_to_index(
366365
entry,
367366
{"Question": "QuestionEmbedding"},
368367
os.environ[

text_2_sql/text_2_sql_core/src/text_2_sql_core/prompts/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import yaml
2+
import os
3+
4+
5+
def load(file):
6+
# Get the directory containing this module
7+
package_dir = os.path.dirname(__file__)
8+
9+
# Construct the absolute path to the file
10+
file_path = os.path.join(package_dir, f"{file}.yaml")
11+
with open(file_path, "r") as file:
12+
file = yaml.safe_load(file)
13+
14+
return file

0 commit comments

Comments
 (0)