Skip to content

Commit

Permalink
8
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro-ao committed Jan 28, 2024
1 parent 9b1398c commit 8f8e630
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from langchain_core.messages import AIMessage, HumanMessage
from langchain_community.document_loaders import WebBaseLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddings


def get_response(user_input):
Expand All @@ -18,8 +20,11 @@ def get_vectorstore_from_url(url):
# split the document into chunks
text_splitter = RecursiveCharacterTextSplitter()
document_chunks = text_splitter.split_documents(document)

# create a vectorstore from the chunks
vector_store = Chroma.from_documents(document_chunks, OpenAIEmbeddings())

return document_chunks
return vector_store


# app config
Expand All @@ -40,8 +45,7 @@ def get_vectorstore_from_url(url):

else:
document_chunks = get_vectorstore_from_url(website_url)
with st.sidebar:
st.write(document_chunks)


# user input
user_query = st.chat_input("Type your message here...")
Expand Down

0 comments on commit 8f8e630

Please sign in to comment.