Skip to content

Commit 7aefaa2

Browse files
Merge pull request #256 from microsoft/dev
fix: merging dev changes to main branch
2 parents d7f2e29 + 5aaf7ec commit 7aefaa2

File tree

6 files changed

+71
-91
lines changed

6 files changed

+71
-91
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
2222
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
2323
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
24-
export GPT_MIN_CAPACITY="50"
24+
export GPT_MIN_CAPACITY="140"
2525
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"
2626
2727
chmod +x infra/scripts/checkquota.sh

src/backend/app_kernel.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# app_kernel.py
22
import asyncio
33
import logging
4+
import os
45
import uuid
56
from typing import Dict, List, Optional
67

@@ -9,6 +10,7 @@
910
from auth.auth_utils import get_authenticated_user_details
1011

1112
# Azure monitoring
13+
from azure.monitor.opentelemetry import configure_azure_monitor
1214
from config_kernel import Config
1315
from event_utils import track_event_if_configured
1416

@@ -32,19 +34,19 @@
3234
# Updated import for KernelArguments
3335
from utils_kernel import initialize_runtime_and_context, rai_success
3436

35-
# # Check if the Application Insights Instrumentation Key is set in the environment variables
36-
# connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
37-
# if connection_string:
38-
# # Configure Application Insights if the Instrumentation Key is found
39-
# configure_azure_monitor(connection_string=connection_string)
40-
# logging.info(
41-
# "Application Insights configured with the provided Instrumentation Key"
42-
# )
43-
# else:
44-
# # Log a warning if the Instrumentation Key is not found
45-
# logging.warning(
46-
# "No Application Insights Instrumentation Key found. Skipping configuration"
47-
# )
37+
# 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:
40+
# Configure Application Insights if the Instrumentation Key is found
41+
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+
)
4850

4951
# Configure logging
5052
logging.basicConfig(level=logging.INFO)
@@ -137,9 +139,8 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
137139
# Convert input task to JSON for the kernel function, add user_id here
138140

139141
# Use the planner to handle the task
140-
result = await group_chat_manager.handle_input_task(input_task)
142+
await group_chat_manager.handle_input_task(input_task)
141143

142-
print(f"Result: {result}")
143144
# Get plan from memory store
144145
plan = await memory_store.get_plan_by_session(input_task.session_id)
145146

@@ -176,7 +177,6 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
176177
}
177178

178179
except Exception as e:
179-
logging.exception(f"Error handling input task: {e}")
180180
track_event_if_configured(
181181
"InputTaskError",
182182
{
@@ -779,18 +779,17 @@ async def delete_all_messages(request: Request) -> Dict[str, str]:
779779
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
780780
user_id = authenticated_user["user_principal_id"]
781781
if not user_id:
782+
track_event_if_configured(
783+
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
784+
)
782785
raise HTTPException(status_code=400, detail="no user")
783786

784787
# Initialize memory context
785788
kernel, memory_store = await initialize_runtime_and_context("", user_id)
786789

787-
logging.info("Deleting all plans")
788790
await memory_store.delete_all_items("plan")
789-
logging.info("Deleting all sessions")
790791
await memory_store.delete_all_items("session")
791-
logging.info("Deleting all steps")
792792
await memory_store.delete_all_items("step")
793-
logging.info("Deleting all agent_messages")
794793
await memory_store.delete_all_items("agent_message")
795794

796795
# Clear the agent factory cache
@@ -840,6 +839,9 @@ async def get_all_messages(request: Request):
840839
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
841840
user_id = authenticated_user["user_principal_id"]
842841
if not user_id:
842+
track_event_if_configured(
843+
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
844+
)
843845
raise HTTPException(status_code=400, detail="no user")
844846

845847
# Initialize memory context

src/backend/context/cosmos_memory_kernel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ async def initialize(self):
8484
id=self._cosmos_container,
8585
partition_key=PartitionKey(path="/session_id"),
8686
)
87-
logging.info("Successfully connected to CosmosDB")
8887
except Exception as e:
8988
logging.error(
9089
f"Failed to initialize CosmosDB container: {e}. Continuing without CosmosDB for testing."

src/backend/handlers/runtime_interrupt_kernel.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ async def on_message(
5555
Returns:
5656
The original message (for pass-through functionality)
5757
"""
58-
print(
59-
f"NeedsUserInputHandler received message: {message} from sender: {sender_type}/{sender_key}"
60-
)
61-
6258
if isinstance(message, GetHumanInputMessage):
6359
self.question_for_human = message
6460
self.messages.append(
@@ -67,7 +63,6 @@ async def on_message(
6763
"content": message.content,
6864
}
6965
)
70-
print("Captured question for human in NeedsUserInputHandler")
7166
elif isinstance(message, GroupChatMessage):
7267
# Ensure we extract content consistently with the original implementation
7368
content = (
@@ -81,7 +76,6 @@ async def on_message(
8176
"content": content,
8277
}
8378
)
84-
print(f"Captured group chat message in NeedsUserInputHandler - {message}")
8579
elif isinstance(message, dict) and "content" in message:
8680
# Handle messages directly from AzureAIAgent
8781
self.question_for_human = GetHumanInputMessage(content=message["content"])
@@ -91,7 +85,6 @@ async def on_message(
9185
"content": message["content"],
9286
}
9387
)
94-
print("Captured question from AzureAIAgent in NeedsUserInputHandler")
9588

9689
return message
9790

@@ -111,7 +104,6 @@ def get_messages(self) -> List[Dict[str, Any]]:
111104
"""Get captured messages and clear buffer."""
112105
messages = self.messages.copy()
113106
self.messages.clear()
114-
print("Returning and clearing captured messages in NeedsUserInputHandler")
115107
return messages
116108

117109

@@ -133,38 +125,28 @@ async def on_message(self, message: Any, sender_type: str = None) -> Any:
133125
Returns:
134126
The original message (for pass-through functionality)
135127
"""
136-
print(
137-
f"on_message called in AssistantResponseHandler with message from sender: {sender_type} - {message}"
138-
)
139-
140128
if hasattr(message, "body") and sender_type in ["writer", "editor"]:
141129
# Ensure we're handling the content consistently with the original implementation
142130
self.assistant_response = (
143131
message.body.content
144132
if hasattr(message.body, "content")
145133
else str(message.body)
146134
)
147-
print("Assistant response set in AssistantResponseHandler")
148135
elif isinstance(message, dict) and "value" in message and sender_type:
149136
# Handle message from AzureAIAgent
150137
self.assistant_response = message["value"]
151-
print(
152-
"Assistant response from AzureAIAgent set in AssistantResponseHandler"
153-
)
154138

155139
return message
156140

157141
@property
158142
def has_response(self) -> bool:
159143
"""Check if response is available."""
160144
has_response = self.assistant_response is not None
161-
print(f"has_response called, returning: {has_response}")
162145
return has_response
163146

164147
def get_response(self) -> Optional[str]:
165148
"""Get captured response."""
166149
response = self.assistant_response
167-
print(f"get_response called, returning: {response}")
168150
return response
169151

170152

@@ -201,7 +183,6 @@ def register_handlers(kernel: sk.Kernel, session_id: str) -> tuple:
201183
kernel.set_variable(f"input_handler_{session_id}", user_input_handler)
202184
kernel.set_variable(f"response_handler_{session_id}", assistant_handler)
203185

204-
print(f"Registered handlers for session {session_id} with kernel")
205186
return user_input_handler, assistant_handler
206187

207188

0 commit comments

Comments
 (0)