Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
export AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}
export AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}
export AZURE_SUBSCRIPTION_ID="${{ secrets.AZURE_SUBSCRIPTION_ID }}"
export GPT_MIN_CAPACITY="50"
export GPT_MIN_CAPACITY="140"
export AZURE_REGIONS="${{ vars.AZURE_REGIONS }}"

chmod +x infra/scripts/checkquota.sh
Expand Down
42 changes: 22 additions & 20 deletions src/backend/app_kernel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# app_kernel.py
import asyncio
import logging
import os
import uuid
from typing import Dict, List, Optional

Expand All @@ -9,6 +10,7 @@
from auth.auth_utils import get_authenticated_user_details

# Azure monitoring
from azure.monitor.opentelemetry import configure_azure_monitor
from config_kernel import Config
from event_utils import track_event_if_configured

Expand All @@ -32,19 +34,19 @@
# Updated import for KernelArguments
from utils_kernel import initialize_runtime_and_context, rai_success

# # Check if the Application Insights Instrumentation Key is set in the environment variables
# connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
# if connection_string:
# # Configure Application Insights if the Instrumentation Key is found
# configure_azure_monitor(connection_string=connection_string)
# logging.info(
# "Application Insights configured with the provided Instrumentation Key"
# )
# else:
# # Log a warning if the Instrumentation Key is not found
# logging.warning(
# "No Application Insights Instrumentation Key found. Skipping configuration"
# )
# Check if the Application Insights Instrumentation Key is set in the environment variables
connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if connection_string:
# Configure Application Insights if the Instrumentation Key is found
configure_azure_monitor(connection_string=connection_string)
logging.info(
"Application Insights configured with the provided Instrumentation Key"
)
else:
# Log a warning if the Instrumentation Key is not found
logging.warning(
"No Application Insights Instrumentation Key found. Skipping configuration"
)

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

# Use the planner to handle the task
result = await group_chat_manager.handle_input_task(input_task)
await group_chat_manager.handle_input_task(input_task)

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

Expand Down Expand Up @@ -176,7 +177,6 @@ async def input_task_endpoint(input_task: InputTask, request: Request):
}

except Exception as e:
logging.exception(f"Error handling input task: {e}")
track_event_if_configured(
"InputTaskError",
{
Expand Down Expand Up @@ -779,18 +779,17 @@ async def delete_all_messages(request: Request) -> Dict[str, str]:
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
user_id = authenticated_user["user_principal_id"]
if not user_id:
track_event_if_configured(
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
)
raise HTTPException(status_code=400, detail="no user")

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

logging.info("Deleting all plans")
await memory_store.delete_all_items("plan")
logging.info("Deleting all sessions")
await memory_store.delete_all_items("session")
logging.info("Deleting all steps")
await memory_store.delete_all_items("step")
logging.info("Deleting all agent_messages")
await memory_store.delete_all_items("agent_message")

# Clear the agent factory cache
Expand Down Expand Up @@ -840,6 +839,9 @@ async def get_all_messages(request: Request):
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
user_id = authenticated_user["user_principal_id"]
if not user_id:
track_event_if_configured(
"UserIdNotFound", {"status_code": 400, "detail": "no user"}
)
raise HTTPException(status_code=400, detail="no user")

# Initialize memory context
Expand Down
1 change: 0 additions & 1 deletion src/backend/context/cosmos_memory_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ async def initialize(self):
id=self._cosmos_container,
partition_key=PartitionKey(path="/session_id"),
)
logging.info("Successfully connected to CosmosDB")
except Exception as e:
logging.error(
f"Failed to initialize CosmosDB container: {e}. Continuing without CosmosDB for testing."
Expand Down
19 changes: 0 additions & 19 deletions src/backend/handlers/runtime_interrupt_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ async def on_message(
Returns:
The original message (for pass-through functionality)
"""
print(
f"NeedsUserInputHandler received message: {message} from sender: {sender_type}/{sender_key}"
)

if isinstance(message, GetHumanInputMessage):
self.question_for_human = message
self.messages.append(
Expand All @@ -67,7 +63,6 @@ async def on_message(
"content": message.content,
}
)
print("Captured question for human in NeedsUserInputHandler")
elif isinstance(message, GroupChatMessage):
# Ensure we extract content consistently with the original implementation
content = (
Expand All @@ -81,7 +76,6 @@ async def on_message(
"content": content,
}
)
print(f"Captured group chat message in NeedsUserInputHandler - {message}")
elif isinstance(message, dict) and "content" in message:
# Handle messages directly from AzureAIAgent
self.question_for_human = GetHumanInputMessage(content=message["content"])
Expand All @@ -91,7 +85,6 @@ async def on_message(
"content": message["content"],
}
)
print("Captured question from AzureAIAgent in NeedsUserInputHandler")

return message

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


Expand All @@ -133,38 +125,28 @@ async def on_message(self, message: Any, sender_type: str = None) -> Any:
Returns:
The original message (for pass-through functionality)
"""
print(
f"on_message called in AssistantResponseHandler with message from sender: {sender_type} - {message}"
)

if hasattr(message, "body") and sender_type in ["writer", "editor"]:
# Ensure we're handling the content consistently with the original implementation
self.assistant_response = (
message.body.content
if hasattr(message.body, "content")
else str(message.body)
)
print("Assistant response set in AssistantResponseHandler")
elif isinstance(message, dict) and "value" in message and sender_type:
# Handle message from AzureAIAgent
self.assistant_response = message["value"]
print(
"Assistant response from AzureAIAgent set in AssistantResponseHandler"
)

return message

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

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


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

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


Expand Down
Loading
Loading