I have a tour booking system, and I’ve created a chatbot using OpenAI. Here are the key points in my approach:
- I have fine-tuned it with my Q&A data.
- I am also using embeddings to provide context with questions, which I have stored in some JSON files.
- Additionally, I need to pass dynamic data to my model, such as tour-related information like available tours, prices, and multiple-person packages. I can obtain this data by calling an API. Since this data could change frequently, I cannot store it as embedded data.
I am currently facing a problem with the third point. How can I fetch data from the API based on the user’s query (human question) and pass it to OpenAI to generate an appropriate answer for the user?
I have attempted to use LangChain for interacting with APIs. You can find more information about LangChain at the following source: Interacting with APIs | 🦜️🔗 Langchain
What LangChain is doing is something like the following: When I ask a question about something, it randomly generates filter/query parameters, as shown in the examples below. However, the API query parameters are fixed.
For example, when I ask the question: “Do you have any tour plans for India?” LangChain attempts to query the API like this:
- User Question: Do you have any tour plans for India?
- LangChain API call: http://127.0.0.1:8000/api/v1/chatbot/trip-info/?country=India
And when I ask the question: “Do you have any tour plans for India in December 2023?” LangChain generates the API call like this:
- User Question: Do you have any tour plans for India in December 2023?
- LangChain API call: http://127.0.0.1:8000/api/v1/chatbot/trip-info/?destination=India&month=December&year=2023
I would greatly appreciate any assistance with this issue. Thank you in advance.