-
Notifications
You must be signed in to change notification settings - Fork 4
Creating tools from swaggers
LangChainJS has a notion of tools to allow agents to communicate with external services. However, hand-rolling these tools is time-consuming. Swagger allows you to specify your API. It is possible to utilize ChatGPT to synthesize code for LangChain tools as explained below - saving you loads of time.
Here's how you can get ChatGPT to generate tools from Swaggers.
You: Here is a Swagger file. Can you summarize for me what it does?
ChatGPT: summarizes the file
You: OK, here's code for a LangChain tool. I want you to summarize what it does.
ChatGPT: summarizes the code
You: Now I want you to generate code for the GET /foo/bar API in the swagger I shared earlier with bla parameter specified via user-input.
ChatGPT: generates the code
You should now copy-paste this code in tools, reference it in your agent, and verify it works. If additional changes are needed, you may edit the code by hand or request ChatGPT to make additional changes.