File size: 751 Bytes
e44b3be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from dotenv import load_dotenv
import streamlit as st
from src.functions_langchain import graph_init, initialize_inmemory_vector_store, load_and_split_documents_from_web

load_dotenv()

st.title("Langchain VectorDB")
st.write("This is a simple demonstration of the Langchain VectorDB.")

vector_store = initialize_inmemory_vector_store()
all_splits = load_and_split_documents_from_web("https://www.gutenberg.org/files/1342/1342-h/1342-h.htm")

# Index chunks
_ = vector_store.add_documents(documents=all_splits)

graph = graph_init(vector_store)

question = st.text_input("Enter a question:")
if st.button("Ask"):
    st.write("Searching for an answer...")
    response = graph.invoke({"question": question})
    st.write(response["answer"])