Skip to content

Commit f413121

Browse files
FDP-Backend_Changes
1 parent b711fc2 commit f413121

File tree

8 files changed

+53
-59
lines changed

8 files changed

+53
-59
lines changed

src/backend/app_config.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ def __init__(self):
4949
self.AZURE_AI_SUBSCRIPTION_ID = self._get_required("AZURE_AI_SUBSCRIPTION_ID")
5050
self.AZURE_AI_RESOURCE_GROUP = self._get_required("AZURE_AI_RESOURCE_GROUP")
5151
self.AZURE_AI_PROJECT_NAME = self._get_required("AZURE_AI_PROJECT_NAME")
52-
self.AZURE_AI_AGENT_PROJECT_CONNECTION_STRING = self._get_required(
53-
"AZURE_AI_AGENT_PROJECT_CONNECTION_STRING"
54-
)
52+
self.AZURE_AI_AGENT_PROJECT_ENDPOINT = self._get_required("AZURE_AI_AGENT_PROJECT_ENDPOINT")
5553

5654
# Cached clients and resources
5755
self._azure_credentials = None
@@ -177,10 +175,8 @@ def get_ai_project_client(self):
177175
"Unable to acquire Azure credentials; ensure DefaultAzureCredential is configured"
178176
)
179177

180-
connection_string = self.AZURE_AI_AGENT_PROJECT_CONNECTION_STRING
181-
self._ai_project_client = AIProjectClient.from_connection_string(
182-
credential=credential, conn_str=connection_string
183-
)
178+
endpoint = self.AZURE_AI_AGENT_PROJECT_ENDPOINT
179+
self._ai_project_client = AIProjectClient(endpoint=endpoint, credential=credential)
184180

185181
return self._ai_project_client
186182
except Exception as exc:

src/backend/app_kernel.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
from utils_kernel import initialize_runtime_and_context, rai_success
3636

3737
# Check if the Application Insights Instrumentation Key is set in the environment variables
38-
connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
39-
if connection_string:
38+
#connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
39+
#if connection_string:
4040
# Configure Application Insights if the Instrumentation Key is found
4141
#configure_azure_monitor(connection_string=connection_string)
42-
logging.info(
43-
"Application Insights configured with the provided Instrumentation Key"
44-
)
45-
else:
46-
# Log a warning if the Instrumentation Key is not found
47-
logging.warning(
48-
"No Application Insights Instrumentation Key found. Skipping configuration"
49-
)
42+
# logging.info(
43+
# "Application Insights configured with the provided Instrumentation Key"
44+
# )
45+
#else:
46+
# # Log a warning if the Instrumentation Key is not found
47+
# logging.warning(
48+
# "No Application Insights Instrumentation Key found. Skipping configuration"
49+
# )
5050

5151
# Configure logging
5252
logging.basicConfig(level=logging.INFO)

src/backend/config_kernel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class Config:
2626
AZURE_AI_SUBSCRIPTION_ID = config.AZURE_AI_SUBSCRIPTION_ID
2727
AZURE_AI_RESOURCE_GROUP = config.AZURE_AI_RESOURCE_GROUP
2828
AZURE_AI_PROJECT_NAME = config.AZURE_AI_PROJECT_NAME
29-
AZURE_AI_AGENT_PROJECT_CONNECTION_STRING = (
30-
config.AZURE_AI_AGENT_PROJECT_CONNECTION_STRING
31-
)
29+
AZURE_AI_AGENT_PROJECT_ENDPOINT = config.AZURE_AI_AGENT_PROJECT_ENDPOINT
3230

3331
@staticmethod
3432
def GetAzureCredentials():

src/backend/kernel_agents/agent_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from event_utils import track_event_if_configured
99
from models.messages_kernel import (ActionRequest, ActionResponse,
1010
AgentMessage, Step, StepStatus)
11-
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent
11+
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent, AzureAIAgentThread
12+
from semantic_kernel.agents.azure_ai.azure_ai_agent_settings import AzureAIAgentSettings
1213
from semantic_kernel.functions import KernelFunction
1314

1415
# Default formatting instructions used across agents

src/backend/kernel_agents/agent_factory.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Import the new AppConfig instance
88
from app_config import config
9-
from azure.ai.projects.models import (ResponseFormatJsonSchema,
9+
from azure.ai.agents.models import (ResponseFormatJsonSchema,
1010
ResponseFormatJsonSchemaType)
1111
from context.cosmos_memory_kernel import CosmosMemoryContext
1212
from kernel_agents.agent_base import BaseAgent
@@ -22,8 +22,8 @@
2222
from kernel_agents.tech_support_agent import TechSupportAgent
2323
from models.messages_kernel import AgentType, PlannerResponsePlan
2424
# pylint:disable=E0611
25-
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent
26-
25+
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent, AzureAIAgentThread
26+
from semantic_kernel.agents.azure_ai.azure_ai_agent_settings import AzureAIAgentSettings
2727
logger = logging.getLogger(__name__)
2828

2929

@@ -265,13 +265,6 @@ async def create_all_agents(
265265
temperature=temperature,
266266
agent_instances=agent_instances, # Pass agent instances to the planner
267267
client=client,
268-
response_format=ResponseFormatJsonSchemaType(
269-
json_schema=ResponseFormatJsonSchema(
270-
name=PlannerResponsePlan.__name__,
271-
description=f"respond with {PlannerResponsePlan.__name__.lower()}",
272-
schema=PlannerResponsePlan.model_json_schema(),
273-
)
274-
),
275268
)
276269
agent_instances[AgentType.PLANNER.value] = (
277270
planner_agent # to pass it to group chat manager

src/backend/kernel_agents/planner_agent.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import uuid
44
from typing import Any, Dict, List, Optional, Tuple
55

6-
from azure.ai.projects.models import (ResponseFormatJsonSchema,
6+
from azure.ai.agents.models import (ResponseFormatJsonSchema,
77
ResponseFormatJsonSchemaType)
88
from context.cosmos_memory_kernel import CosmosMemoryContext
99
from event_utils import track_event_if_configured
@@ -133,37 +133,43 @@ async def create(
133133
try:
134134
logging.info("Initializing PlannerAgent from async init azure AI Agent")
135135

136+
# Construct response_format with the required 'type' field
137+
response_format = {
138+
"type": "json_schema", # Add the missing type field
139+
"json_schema": {
140+
"name": PlannerResponsePlan.__name__,
141+
"description": f"respond with {PlannerResponsePlan.__name__.lower()}",
142+
"schema": PlannerResponsePlan.model_json_schema()
143+
}
144+
}
145+
136146
# Create the Azure AI Agent using AppConfig with string instructions
137147
agent_definition = await cls._create_azure_ai_agent_definition(
138148
agent_name=agent_name,
139-
instructions=cls._get_template(), # Pass the formatted string, not an object
149+
instructions=cls._get_template(), # Pass the formatted string
140150
temperature=0.0,
141-
response_format=ResponseFormatJsonSchemaType(
142-
json_schema=ResponseFormatJsonSchema(
143-
name=PlannerResponsePlan.__name__,
144-
description=f"respond with {PlannerResponsePlan.__name__.lower()}",
145-
schema=PlannerResponsePlan.model_json_schema(),
146-
)
147-
),
151+
response_format=response_format,
148152
)
149153

150-
return cls(
151-
session_id=session_id,
152-
user_id=user_id,
153-
memory_store=memory_store,
154-
tools=tools,
155-
system_message=system_message,
156-
agent_name=agent_name,
157-
available_agents=available_agents,
158-
agent_instances=agent_instances,
159-
client=client,
160-
definition=agent_definition,
161-
)
162-
163-
except Exception as e:
164-
logging.error(f"Failed to create Azure AI Agent for PlannerAgent: {e}")
154+
except Exception as exc:
155+
logging.error("Error initializing PlannerAgent definition: %s", exc)
165156
raise
166157

158+
return cls(
159+
session_id=session_id,
160+
user_id=user_id,
161+
memory_store=memory_store,
162+
tools=tools,
163+
system_message=system_message,
164+
agent_name=agent_name,
165+
available_agents=available_agents,
166+
agent_instances=agent_instances,
167+
client=client,
168+
definition=agent_definition,
169+
)
170+
171+
172+
167173
async def handle_input_task(self, input_task: InputTask) -> str:
168174
"""Handle the initial input task from the user.
169175

src/backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ dependencies = [
2626
"pytest-cov==5.0.0",
2727
"python-dotenv>=1.1.0",
2828
"python-multipart>=0.0.20",
29-
"semantic-kernel>=1.28.1",
29+
"semantic-kernel>=1.32.2",
3030
"uvicorn>=0.34.2",
3131
]

src/backend/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ opentelemetry-instrumentation-fastapi
1414
opentelemetry-instrumentation-openai
1515
opentelemetry-exporter-otlp-proto-http
1616

17-
semantic-kernel[azure]==1.28.1
18-
azure-ai-projects==1.0.0b10
19-
openai
17+
semantic-kernel[azure]==1.32.2
18+
azure-ai-projects==1.0.0b11
19+
openai==1.84.0
2020
azure-ai-inference==1.0.0b9
2121
azure-search-documents
2222
azure-ai-evaluation

0 commit comments

Comments
 (0)