Skip to content

Commit 5aa84ca

Browse files
committed
Address Matt's feedback
1 parent 9fb2fb1 commit 5aa84ca

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

app/backend/chat_history/cosmosdb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
CONFIG_CHAT_HISTORY_COSMOS_ENABLED,
1111
CONFIG_COSMOS_HISTORY_CLIENT,
1212
CONFIG_COSMOS_HISTORY_CONTAINER,
13+
CONFIG_COSMOS_HISTORY_VERSION,
1314
CONFIG_CREDENTIAL,
1415
)
1516
from decorators import authenticated
@@ -43,6 +44,7 @@ async def post_chat_history(auth_claims: Dict[str, Any]):
4344
# Insert the session item:
4445
session_item = {
4546
"id": session_id,
47+
"version": current_app.config[CONFIG_COSMOS_HISTORY_VERSION],
4648
"session_id": session_id,
4749
"entra_oid": entra_oid,
4850
"type": "session",
@@ -56,11 +58,13 @@ async def post_chat_history(auth_claims: Dict[str, Any]):
5658
message_pair_items.append(
5759
{
5860
"id": f"{session_id}-{ind}",
61+
"version": current_app.config[CONFIG_COSMOS_HISTORY_VERSION],
5962
"session_id": session_id,
6063
"entra_oid": entra_oid,
6164
"type": "message_pair",
6265
"question": message_pair[0],
6366
"response": message_pair[1],
67+
"order": ind,
6468
"timestamp": None,
6569
}
6670
)
@@ -193,7 +197,7 @@ async def delete_chat_history_session(auth_claims: Dict[str, Any], session_id: s
193197

194198
try:
195199
res = container.query_items(
196-
query="SELECT * FROM c WHERE c.session_id = @session_id",
200+
query="SELECT c.id FROM c WHERE c.session_id = @session_id",
197201
parameters=[dict(name="@entra_oid", value=entra_oid), dict(name="@session_id", value=session_id)],
198202
partition_key=[entra_oid, session_id],
199203
)
@@ -237,6 +241,7 @@ async def setup_clients():
237241

238242
current_app.config[CONFIG_COSMOS_HISTORY_CLIENT] = cosmos_client
239243
current_app.config[CONFIG_COSMOS_HISTORY_CONTAINER] = cosmos_container
244+
current_app.config[CONFIG_COSMOS_HISTORY_VERSION] = os.environ["AZURE_CHAT_HISTORY_VERSION"]
240245

241246

242247
@chat_history_cosmosdb_bp.after_app_serving

app/backend/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
CONFIG_CHAT_HISTORY_COSMOS_ENABLED = "chat_history_cosmos_enabled"
2727
CONFIG_COSMOS_HISTORY_CLIENT = "cosmos_history_client"
2828
CONFIG_COSMOS_HISTORY_CONTAINER = "cosmos_history_container"
29+
CONFIG_COSMOS_HISTORY_VERSION = "cosmos_history_version"

app/frontend/src/components/LoginButton/LoginButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const LoginButton = () => {
3535
})
3636
.catch(error => console.log(error))
3737
.then(async () => {
38-
debugger;
3938
setLoggedIn(await checkLoggedIn(instance));
4039
setUsername((await getUsername(instance)) ?? "");
4140
});

infra/main.bicep

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ param cosmosDbLocation string = ''
7070
param cosmosDbAccountName string = ''
7171
param cosmosDbThroughput int = 400
7272
param chatHistoryDatabaseName string = 'chat-database'
73-
param chatHistoryContainerName string = 'chat-history-container'
73+
param chatHistoryContainerName string = 'chat-history-v2'
74+
param chatHistoryVersion string = 'cosmosdb-v2'
7475

7576
// https://learn.microsoft.com/azure/ai-services/openai/concepts/models?tabs=python-secure%2Cstandard%2Cstandard-chat-completions#standard-deployment-model-availability
7677
@description('Location for the OpenAI resource group')
@@ -375,6 +376,7 @@ var appEnvVariables = {
375376
AZURE_COSMOSDB_ACCOUNT: (useAuthentication && useChatHistoryCosmos) ? cosmosDb.outputs.name : ''
376377
AZURE_CHAT_HISTORY_DATABASE: chatHistoryDatabaseName
377378
AZURE_CHAT_HISTORY_CONTAINER: chatHistoryContainerName
379+
AZURE_CHAT_HISTORY_VERSION: chatHistoryVersion
378380
// Shared by all OpenAI deployments
379381
OPENAI_HOST: openAiHost
380382
AZURE_OPENAI_EMB_MODEL_NAME: embedding.modelName
@@ -1215,6 +1217,7 @@ output AZURE_SEARCH_SERVICE_ASSIGNED_USERID string = searchService.outputs.princ
12151217
output AZURE_COSMOSDB_ACCOUNT string = (useAuthentication && useChatHistoryCosmos) ? cosmosDb.outputs.name : ''
12161218
output AZURE_CHAT_HISTORY_DATABASE string = chatHistoryDatabaseName
12171219
output AZURE_CHAT_HISTORY_CONTAINER string = chatHistoryContainerName
1220+
output AZURE_CHAT_HISTORY_VERSION string = chatHistoryVersion
12181221

12191222
output AZURE_STORAGE_ACCOUNT string = storage.outputs.name
12201223
output AZURE_STORAGE_CONTAINER string = storageContainerName

0 commit comments

Comments
 (0)