Skip to content

Commit a7d1e12

Browse files
author
Shreyas-Microsoft
committed
fdp code level changes- hardcoded endpoint
1 parent 8ec88b6 commit a7d1e12

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

src/backend/common/config/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self):
3838
self.azure_queue_name = os.getenv("AZURE_QUEUE_NAME")
3939

4040
self.azure_openai_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
41+
self.ai_project_endpoint = os.getenv("AI_PROJECT_ENDPOINT")
4142
self.migrator_agent_model_deploy = os.getenv("MIGRATOR_AGENT_MODEL_DEPLOY")
4243
self.picker_agent_model_deploy = os.getenv("PICKER_AGENT_MODEL_DEPLOY")
4344
self.fixer_agent_model_deploy = os.getenv("FIXER_AGENT_MODEL_DEPLOY")
@@ -62,3 +63,4 @@ def get_azure_credentials(self):
6263

6364

6465
app_config = Config()
66+
print(f"[DEBUG] AI_PROJECT_ENDPOINT: '{os.getenv('AI_PROJECT_ENDPOINT')}'")

src/backend/sql_agents/agents/agent_base.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import logging
44
from abc import ABC, abstractmethod
55
from typing import Any, Generic, List, Optional, TypeVar, Union
6+
import json
67

7-
from azure.ai.projects.models import (
8-
ResponseFormatJsonSchema,
9-
ResponseFormatJsonSchemaType,
10-
)
8+
# Removed broken import:
9+
# from azure.ai.projects.models import ResponseFormatJsonSchema, ResponseFormatJsonSchemaType
1110

1211
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent
1312
from semantic_kernel.functions import KernelArguments
@@ -107,23 +106,30 @@ async def setup(self) -> AzureAIAgent:
107106

108107
kernel_args = self.get_kernel_arguments()
109108

109+
# Define an agent on the Azure AI agent service
110+
# Construct response_format manually
111+
response_format = None
112+
if self.response_object:
113+
response_format = {
114+
"type": "json_schema",
115+
"json_schema": {
116+
"name": self.response_object.__name__,
117+
"description": f"respond with {self.response_object.__name__.lower()}",
118+
"schema": self.response_object.model_json_schema()
119+
}
120+
}
121+
110122
try:
111-
# Define an agent on the Azure AI agent service
112123
agent_definition = await self.config.ai_project_client.agents.create_agent(
113124
model=_deployment_name,
114125
name=_name,
115126
instructions=template_content,
116127
temperature=self.temperature,
117-
response_format=ResponseFormatJsonSchemaType(
118-
json_schema=ResponseFormatJsonSchema(
119-
name=self.response_object.__name__,
120-
description=f"respond with {self.response_object.__name__.lower()}",
121-
schema=self.response_object.model_json_schema(),
122-
)
123-
),
128+
response_format=response_format,
124129
)
125130
except Exception as exc:
126131
logger.error("Error creating agent definition: %s", exc)
132+
raise
127133
# Set the agent definition with the response format
128134

129135
# Create a Semantic Kernel agent based on the agent definition

src/backend/sql_agents/process_batch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from fastapi import HTTPException
2525

2626

27-
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent # pylint: disable=E0611
27+
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent, AzureAIAgentSettings # pylint: disable=E0611
2828
from semantic_kernel.contents import AuthorRole
2929
from semantic_kernel.exceptions.service_exceptions import ServiceResponseException
3030

@@ -57,10 +57,11 @@ async def process_batch_async(
5757
except Exception as exc:
5858
logger.error("Error updating batch status. %s", exc)
5959

60+
ai_agent_settings = AzureAIAgentSettings()
6061
# Add client and auto cleanup
6162
async with (
6263
DefaultAzureCredential() as creds,
63-
AzureAIAgent.create_client(credential=creds) as client,
64+
AzureAIAgent.create_client(credential=creds, endpoint="https://fdp-rg-psl-codmod-main-resource.services.ai.azure.com/api/projects/fdp-rg-psl-codmod-main") as client,
6465
):
6566

6667
# setup all agent settings and agents per batch

0 commit comments

Comments
 (0)