.streamlit
. Inside that folder, create a file called secrets.toml
. Inside secrets.toml
add your PREMAI_API_KEY
and PROJECT_ID
as shown here:
app.py
we import our required libraries as shown below:
map_template
, instructs the LLM to take all the documents (in this case, the chunks of the documents extracted from the URL), identify the central theme, extract useful information, etc. In the second template, reduce_template
, we ask it to summarize the document (a combined summary of the chunks) into a single summary that provides valuable insights to the reader.
WebBaseLoader
and the document from the given URL. We also load the CharacterTextSplitter to split the documents into chunks.map_template
and reduce_template
from the above templates.map_chain
and reduce_chain
from langchain LLMChain
, which will use an LLM (in our case, a ChatPremAI client) and the corresponding template.combined_document_chain
which combines all the summarized chunks (stacking each of them one after the other) using the StuffDocumentsChain.reduce_document_chain
takes those combined documents and runs the reduce (i.e. another summarization) on those stuffed documents.summarize_url
function and creates an expandable card-like container which contains the summary of the URL.
_
because there is no use for this returned list of summaries. However, we can extend this by uploading all the summaries and documents (collected from passed) to Prem Repositories. We will show that in our following tutorial.
Congratulations you have created your first application using Prem AI. To run this application you just need to run the following command: