langchain: return attachments in _get_response (#30853)

This is a PR to return the message attachments in _get_response, as when
files are generated these attachments are not returned thus generated
files cannot be retrieved

Fixes issue: https://github.com/langchain-ai/langchain/issues/30851
This commit is contained in:
Georgi Stefanov 2025-04-25 04:39:11 +03:00 committed by GitHub
parent 09c1991e96
commit d30c56a8c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -584,6 +584,9 @@ class OpenAIAssistantRunnable(RunnableSerializable[dict, OutputType]):
answer: Any = [ answer: Any = [
msg_content for msg in new_messages for msg_content in msg.content msg_content for msg in new_messages for msg_content in msg.content
] ]
attachments = [
attachment for msg in new_messages for attachment in msg.attachments
]
if all( if all(
( (
isinstance(content, openai.types.beta.threads.TextContentBlock) isinstance(content, openai.types.beta.threads.TextContentBlock)
@ -601,6 +604,7 @@ class OpenAIAssistantRunnable(RunnableSerializable[dict, OutputType]):
"output": answer, "output": answer,
"thread_id": run.thread_id, "thread_id": run.thread_id,
"run_id": run.id, "run_id": run.id,
"attachments": attachments,
}, },
log="", log="",
run_id=run.id, run_id=run.id,