Skip to content

Commit cc65850

Browse files
committed
add comment
1 parent 7eedb88 commit cc65850

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llama_stack/providers/utils/inference/inference_store.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the root directory of this source tree.
66
import asyncio
77
from typing import Any
8+
89
from sqlalchemy.exc import IntegrityError
910

1011
from llama_stack.apis.inference import (
@@ -144,15 +145,15 @@ async def _write_chat_completion(
144145
data=record_data,
145146
)
146147
except IntegrityError as e:
148+
# Duplicate chat completion IDs can be generated during tests especially if they are replaying
149+
# recorded responses across different tests. No need to warn or error under those circumstances.
150+
# In the wild, this is not likely to happen at all (no evidence) so we aren't really hiding any problem.
151+
147152
# Check if it's a unique constraint violation
148153
error_message = str(e.orig) if e.orig else str(e)
149154
if self._is_unique_constraint_error(error_message):
150155
# Update the existing record instead
151-
await self.sql_store.update(
152-
table="chat_completions",
153-
data=record_data,
154-
where={"id": data["id"]}
155-
)
156+
await self.sql_store.update(table="chat_completions", data=record_data, where={"id": data["id"]})
156157
else:
157158
# Re-raise if it's not a unique constraint error
158159
raise

0 commit comments

Comments
 (0)