|
5 | 5 | from datetime import datetime, timezone |
6 | 6 | from typing import Any, Dict, List, Optional, Tuple |
7 | 7 |
|
8 | | -from azure.core.credentials import AzureKeyCredential |
9 | | -from azure.core.exceptions import (ClientAuthenticationError, |
10 | | - HttpResponseError, ResourceNotFoundError) |
11 | | -from azure.identity import DefaultAzureCredential |
| 8 | +from azure.core.exceptions import ( |
| 9 | + ClientAuthenticationError, |
| 10 | + HttpResponseError, |
| 11 | + ResourceNotFoundError, |
| 12 | +) |
| 13 | + |
12 | 14 | from azure.search.documents.indexes import SearchIndexClient |
13 | 15 | from common.config.app_config import config |
14 | 16 | from common.database.database_base import DatabaseBase |
15 | | -from common.models.messages_kernel import (StartingTask, TeamAgent, |
16 | | - TeamConfiguration) |
| 17 | +from common.models.messages_kernel import ( |
| 18 | + StartingTask, |
| 19 | + TeamAgent, |
| 20 | + TeamConfiguration, |
| 21 | + UserCurrentTeam, |
| 22 | +) |
17 | 23 | from v3.common.services.foundry_service import FoundryService |
18 | 24 |
|
19 | 25 |
|
@@ -218,6 +224,52 @@ async def get_team_configuration( |
218 | 224 | self.logger.error("Error retrieving team configuration: %s", str(e)) |
219 | 225 | return None |
220 | 226 |
|
| 227 | + async def delete_user_current_team(self, user_id: str) -> bool: |
| 228 | + """ |
| 229 | + Delete the current team for a user. |
| 230 | +
|
| 231 | + Args: |
| 232 | + user_id: User ID to delete the current team for |
| 233 | +
|
| 234 | + Returns: |
| 235 | + True if successful, False otherwise |
| 236 | + """ |
| 237 | + try: |
| 238 | + await self.memory_context.delete_user_current_team(user_id) |
| 239 | + self.logger.info("Successfully deleted current team for user %s", user_id) |
| 240 | + return True |
| 241 | + |
| 242 | + except Exception as e: |
| 243 | + self.logger.error("Error deleting current team: %s", str(e)) |
| 244 | + return False |
| 245 | + |
| 246 | + async def handle_team_selection(self, user_id: str, team_id: str) -> bool: |
| 247 | + """ |
| 248 | + Set a default team for a user. |
| 249 | +
|
| 250 | + Args: |
| 251 | + user_id: User ID to set the default team for |
| 252 | + team_id: Team ID to set as default |
| 253 | +
|
| 254 | + Returns: |
| 255 | + True if successful, False otherwise |
| 256 | + """ |
| 257 | + try: |
| 258 | + current_team = await self.memory_context.get_current_team(user_id, team_id) |
| 259 | + |
| 260 | + if current_team is None: |
| 261 | + current_team = UserCurrentTeam(user_id=user_id, team_id=team_id) |
| 262 | + await self.memory_context.set_current_team(current_team) |
| 263 | + return True |
| 264 | + else: |
| 265 | + current_team.team_id = team_id |
| 266 | + await self.memory_context.update_current_team(current_team) |
| 267 | + return True |
| 268 | + |
| 269 | + except Exception as e: |
| 270 | + self.logger.error("Error setting default team: %s", str(e)) |
| 271 | + return False |
| 272 | + |
221 | 273 | async def get_all_team_configurations( |
222 | 274 | self, user_id: str |
223 | 275 | ) -> List[TeamConfiguration]: |
@@ -345,7 +397,7 @@ async def validate_team_models( |
345 | 397 | missing_models: List[str] = [] |
346 | 398 | for model in required_models: |
347 | 399 | # Temporary bypass for known deployed models |
348 | | - if model.lower() in ['gpt-4o', 'o3', 'gpt-4', 'gpt-35-turbo']: |
| 400 | + if model.lower() in ["gpt-4o", "o3", "gpt-4", "gpt-35-turbo"]: |
349 | 401 | continue |
350 | 402 | if model not in available_models: |
351 | 403 | missing_models.append(model) |
|
0 commit comments