Idea/Question: Initial idea for allowing OpenAI default tools #14329
+22
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I am trying to come up with a way to allow the
LmChatOpenAi
node to make use of the OpenAI built-inweb_search_preview
tool. I believe this would allow the models to have similar web search and research capabilities to what is exposed through Chat GPT when using the web search functionality.Note: This PR does not work, it is just to show the idea of what I was thinking and get feedback from someone else that understands the code better. It does allow configuring the setting, but it seems to break something in lang-chain.
The error I get is:
So I think something about calling the
bind_tools
method this way is returning a new object that doesn't have the correct state to be used later.Related Linear tickets, Github issues, and Community forum posts
Addresses the question I posed here: https://community.n8n.io/t/any-way-to-use-openai-chat-model-with-default-open-ai-tool-web-search-preview/95318
Details
I would like to use the OpenAI Chat Model with the default tool provided by OpenAI for web searches: web_search_preview
As I understand it, this would allow the requests to the Open AI Chat Model to use web search’s to supplement the response similar to what is shown on the ChatGPT site.
The OpenAI documentation shows how to use this through their API: https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses
I looked into LangChain and it appears that this is supported in their API as well as a pass through. See: ChatOpenAI | 🦜️🔗 LangChain
So I tracked down the n8n node code to see if there was any way to pass this in through a configuration. From what I can tell there is not. See:
n8n/packages/@n8n/nodes-langchain/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.ts
Line 232 in cf37ee3
I think it should be pretty easy for someone that knows the codebase well to add another option to allow passing in the names of some default tools or something similar. Unfortunately I don’t know n8n well enough to run it in development or how all of this works. But I thought I would ask here to see if I am missing something or if anyone that does know would be willing to give it a try.
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)