88 ResponseFormatJsonSchema ,
99 ResponseFormatJsonSchemaType ,
1010)
11- from common .config .config import app_config
1211from common .models .api import AgentType
1312from semantic_kernel .agents .azure_ai .azure_ai_agent import AzureAIAgent
1413from semantic_kernel .functions import KernelArguments
15- from sql_agents .agent_config import AgentModelDeployment , AgentsConfigDialect
14+ from sql_agents .agent_config import AgentBaseConfig
1615from sql_agents .helpers .utils import get_prompt
1716
1817# Type variable for response models
19- T = TypeVar ('T' )
18+ T = TypeVar ("T" )
2019
2120logger = logging .getLogger (__name__ )
2221logger .setLevel (logging .DEBUG )
@@ -28,12 +27,12 @@ class BaseSQLAgent(Generic[T], ABC):
2827 def __init__ (
2928 self ,
3029 agent_type : AgentType ,
31- config : AgentsConfigDialect ,
32- deployment_name : AgentModelDeployment ,
30+ config : AgentBaseConfig ,
31+ deployment_name : None ,
3332 temperature : float = 0.0 ,
3433 ):
3534 """Initialize the base SQL agent.
36-
35+
3736 Args:
3837 agent_type: The type of agent to create.
3938 config: The dialect configuration for the agent.
@@ -55,7 +54,7 @@ def response_schema(self) -> type:
5554 @property
5655 def num_candidates (self ) -> Optional [int ]:
5756 """Get the number of candidates for this agent.
58-
57+
5958 Returns:
6059 The number of candidates, or None if not applicable.
6160 """
@@ -64,32 +63,32 @@ def num_candidates(self) -> Optional[int]:
6463 @property
6564 def plugins (self ) -> Optional [List [Union [str , Any ]]]:
6665 """Get the plugins for this agent.
67-
66+
6867 Returns:
6968 A list of plugins, or None if not applicable.
7069 """
7170 return None
7271
7372 def get_kernel_arguments (self ) -> KernelArguments :
7473 """Get the kernel arguments for this agent.
75-
74+
7675 Returns:
7776 A KernelArguments object with the necessary arguments.
7877 """
7978 args = {
80- "target" : self .config .sql_dialect_out ,
81- "source" : self .config .sql_dialect_in ,
79+ "target" : self .config .sql_to ,
80+ "source" : self .config .sql_from ,
8281 }
83-
82+
8483 if self .num_candidates is not None :
8584 args ["numCandidates" ] = str (self .num_candidates )
86-
85+
8786 return KernelArguments (** args )
8887
8988 async def setup (self ) -> AzureAIAgent :
9089 """Setup the agent with Azure AI."""
91- _deployment_name = self .deployment_name .value
9290 _name = self .agent_type .value
91+ _deployment_name = self .config .model_type .get (self .agent_type )
9392
9493 try :
9594 template_content = get_prompt (_name )
@@ -100,7 +99,7 @@ async def setup(self) -> AzureAIAgent:
10099 kernel_args = self .get_kernel_arguments ()
101100
102101 # Define an agent on the Azure AI agent service
103- agent_definition = await app_config .ai_project_client .agents .create_agent (
102+ agent_definition = await self . config .ai_project_client .agents .create_agent (
104103 model = _deployment_name ,
105104 name = _name ,
106105 instructions = template_content ,
@@ -116,15 +115,15 @@ async def setup(self) -> AzureAIAgent:
116115
117116 # Create a Semantic Kernel agent based on the agent definition
118117 agent_kwargs = {
119- "client" : app_config .ai_project_client ,
118+ "client" : self . config .ai_project_client ,
120119 "definition" : agent_definition ,
121120 "arguments" : kernel_args ,
122121 }
123-
122+
124123 # Add plugins if specified
125124 if self .plugins :
126125 agent_kwargs ["plugins" ] = self .plugins
127-
126+
128127 self .agent = AzureAIAgent (** agent_kwargs )
129128
130129 return self .agent
@@ -139,4 +138,4 @@ async def execute(self, inputs: Any) -> T:
139138 """Execute the agent with the given inputs."""
140139 agent = await self .get_agent ()
141140 response = await agent .invoke (inputs )
142- return response # Type will be inferred from T
141+ return response # Type will be inferred from T
0 commit comments