Skip to content

Commit a0dd6b9

Browse files
committed
Revert unneeded changes
1 parent 4681f80 commit a0dd6b9

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

app/backend/chat_history/cosmosdb.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import logging
21
import os
32
import time
43
from typing import Any, Dict, Union
54

6-
from azure.cosmos import exceptions
75
from azure.cosmos.aio import ContainerProxy, CosmosClient
86
from azure.identity.aio import AzureDeveloperCliCredential, ManagedIdentityCredential
97
from quart import Blueprint, current_app, jsonify, make_response, request
@@ -17,8 +15,6 @@
1715
from decorators import authenticated
1816
from error import error_response
1917

20-
logger = logging.getLogger("scripts")
21-
2218
chat_history_cosmosdb_bp = Blueprint("chat_history_cosmos", __name__, static_folder="static")
2319

2420

@@ -71,14 +67,7 @@ async def post_chat_history(auth_claims: Dict[str, Any]):
7167

7268
batch_operations = [("upsert", (session,))] + [("upsert", (message,)) for message in messages]
7369

74-
try:
75-
await container.execute_item_batch(batch_operations=batch_operations, partition_key=[entra_oid, session_id])
76-
except exceptions.CosmosBatchOperationError as e:
77-
error_operation_index = e.error_index
78-
error_operation_response = e.operation_responses[error_operation_index]
79-
error_operation = batch_operations[error_operation_index]
80-
logger.error(f"Batch operation failed: {error_operation_response} for operation {error_operation}")
81-
return jsonify({"error": "Batch operation failed"}), 400
70+
await container.execute_item_batch(batch_operations=batch_operations, partition_key=[entra_oid, session_id])
8271
return jsonify({}), 201
8372
except Exception as error:
8473
return error_response(error, "/chat_history")
@@ -99,7 +88,6 @@ async def get_chat_history_sessions(auth_claims: Dict[str, Any]):
9988
return jsonify({"error": "User OID not found"}), 401
10089

10190
try:
102-
# get the count and continuation token from the request URL
10391
count = int(request.args.get("count", 10))
10492
continuation_token = request.args.get("continuation_token")
10593

@@ -110,7 +98,6 @@ async def get_chat_history_sessions(auth_claims: Dict[str, Any]):
11098
max_item_count=count,
11199
)
112100

113-
# set the continuation token for the next page
114101
pager = res.by_page(continuation_token)
115102

116103
# Get the first page, and the continuation token

0 commit comments

Comments
 (0)