Build a Document QA generator with Langchain and Streamlit
In this post, I will be explaining about with_structured_output api of langchain, which helps to output the response in the predefined output model. At the end of this blog, we will be building a tool which generates a multiple choice questions along answers from the PDF uploaded. I find it is easy to host the solution on streamlit, it has one click deployment hosted on their community cloud and it is Free. The demo app can be found here Pre-requisites Groq API key to access LLM models - you can get one from here Streamlit account to host the application Python experience Tech Stack Langchain - used to integrate LLM models fitz - used to read the pdf file contents Project Setup Create a python virtual environment using venv with below command, read more about venv here $ python -m venv .venv activate virtual environment with below command $ source /bin/activate Create a file requirements.txt with below packages. streamlit streamlit-feedback langchain langchain-community langchain-groq Run pip install command to install the required packages. pip install -r requirements.txt Build Streamlit app Create a file main.py and setup the basic streamlit app with below content import streamlit as st st.set_page_config( page_title="Document Questionnaire generator", page_icon="
In this post, I will be explaining about with_structured_output
api of langchain, which helps to output the response in the predefined output model.
At the end of this blog, we will be building a tool which generates a multiple choice questions along answers from the PDF uploaded. I find it is easy to host the solution on streamlit, it has one click deployment hosted on their community cloud and it is Free.
The demo app can be found here
Pre-requisites
Groq API key to access LLM models - you can get one from here
Streamlit account to host the application
Python experience
Tech Stack
Langchain - used to integrate LLM models
fitz - used to read the pdf file contents
Project Setup
- Create a python virtual environment using venv with below command, read more about venv here
$ python -m venv .venv
- activate virtual environment with below command
$ source
- Create a file requirements.txt with below packages.
streamlit
streamlit-feedback
langchain
langchain-community
langchain-groq
- Run pip install command to install the required packages.
pip install -r requirements.txt
Build Streamlit app
- Create a file main.py and setup the basic streamlit app with below content
import streamlit as st
st.set_page_config(
page_title="Document Questionnaire generator",
page_icon="
What's Your Reaction?