mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 23:54:14 +00:00
Fixed an issue with the OpenAI Assistant's 'retrieval' tool and adding support for the 'attachments' parameter (#30006)
PR Title: langchain: add attachments support in OpenAIAssistantRunnable PR Description: This PR fixes an issue with the "retrieval" tool (internally named "file_search") in the OpenAI Assistant by adding support for the "attachments" parameter in the invoke method. This change allows files to be linked to messages when they are inserted into threads, which is essential for utilizing OpenAI's Retrieval Augmented Generation (RAG) feature. Issue: N/A Dependencies: None Twitter handle: N/A --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
4710c1fa8c
commit
5f0102242a
@ -114,7 +114,7 @@ def _is_assistants_builtin_tool(
|
||||
tool: Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool],
|
||||
) -> bool:
|
||||
"""Determine if tool corresponds to OpenAI Assistants built-in."""
|
||||
assistants_builtin_tools = ("code_interpreter", "retrieval")
|
||||
assistants_builtin_tools = ("code_interpreter", "file_search")
|
||||
return (
|
||||
isinstance(tool, dict)
|
||||
and ("type" in tool)
|
||||
@ -128,7 +128,7 @@ def _get_assistants_tool(
|
||||
"""Convert a raw function/class to an OpenAI tool.
|
||||
|
||||
Note that OpenAI assistants supports several built-in tools,
|
||||
such as "code_interpreter" and "retrieval."
|
||||
such as "code_interpreter" and "file_search".
|
||||
"""
|
||||
if _is_assistants_builtin_tool(tool):
|
||||
return tool # type: ignore
|
||||
@ -300,6 +300,8 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
|
||||
max_completion_tokens: Allow setting max_completion_tokens for this run.
|
||||
max_prompt_tokens: Allow setting max_prompt_tokens for this run.
|
||||
run_metadata: Metadata to associate with new run.
|
||||
attachments: A list of files attached to the message, and the
|
||||
tools they should be added to.
|
||||
config: Runnable config. Defaults to None.
|
||||
|
||||
Return:
|
||||
@ -333,6 +335,7 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
|
||||
"role": "user",
|
||||
"content": input["content"],
|
||||
"metadata": input.get("message_metadata"),
|
||||
"attachments": input.get("attachments"),
|
||||
}
|
||||
],
|
||||
"metadata": input.get("thread_metadata"),
|
||||
|
Loading…
Reference in New Issue
Block a user