mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-31 10:23:18 +00:00
openai[patch]: handle annotation change in openai==1.82.0 (#31597)
https://github.com/openai/openai-python/pull/2372/files#diff-91cfd5576e71b4b72da91e04c3a029bab50a72b5f7a2ac8393fca0a06e865fb3
This commit is contained in:
@@ -3540,14 +3540,12 @@ def _convert_responses_chunk_to_generation_chunk(
|
||||
{"type": "text", "text": chunk.delta, "index": chunk.content_index}
|
||||
)
|
||||
elif chunk.type == "response.output_text.annotation.added":
|
||||
content.append(
|
||||
{
|
||||
"annotations": [
|
||||
chunk.annotation.model_dump(exclude_none=True, mode="json")
|
||||
],
|
||||
"index": chunk.content_index,
|
||||
}
|
||||
)
|
||||
if isinstance(chunk.annotation, dict):
|
||||
# Appears to be a breaking change in openai==1.82.0
|
||||
annotation = chunk.annotation
|
||||
else:
|
||||
annotation = chunk.annotation.model_dump(exclude_none=True, mode="json")
|
||||
content.append({"annotations": [annotation], "index": chunk.content_index})
|
||||
elif chunk.type == "response.created":
|
||||
response_metadata["id"] = chunk.response.id
|
||||
elif chunk.type == "response.completed":
|
||||
|
Reference in New Issue
Block a user