Document QA
Build a Document QA flow for a chatbot application using OpenAI.
This flow extends the Basic Prompting flow with File loader and Parse data components that load a file from your local machine and convert the loaded data into plain text.
This loaded data then informs the Open AI component’s responses.
Open Langflow and start a new project
-
In the Astra Portal header, switch your active app from Astra DB Serverless to Langflow.
-
In Langflow, click New Project, and then select the Document QA project.
This opens a starter project with the necessary components to run a chatbot application using OpenAI.
Document QA flow
The Document QA flow consists of these components:
-
The File component loads a file from your local machine.
-
The Parse Data component parses and converts data into plain text.
-
The Chat Input component accepts user input to the chat.
-
The Prompt component combines the user input with a user-defined prompt.
-
The OpenAI model component sends the user input and prompt to the OpenAI API and receives a response.
-
The Chat Output component prints the flow’s output to the chat.
Run the Document QA flow
-
Add your credentials to the Open AI component. The fastest and most secure way to add credentials is with Langflow’s Global Variables.
-
Click
Settings, and then click Global Variables. -
Click Add New.
-
Name your variable. Paste your API key in the Value field.
-
In the Apply To Fields field, select the field you want to globally apply this variable to.
-
Click Save Variable.
-
-
Click
Playground to start a chat session. -
Ask a question about the document you uploaded in the File component. The OpenAI component will answer your question with information from the document.
Now that your query has completed the journey from Chat input to Chat output, you have completed the Document QA flow.
Next steps
To interact with this flow as an API endpoint, see the Langflow API.