Spaces:
Runtime error
Runtime error
Commit
•
2c8d5d0
1
Parent(s):
e697358
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
2 |
from langchain.text_splitter import CharacterTextSplitter
|
3 |
from langchain.vectorstores import Chroma
|
|
|
|
|
|
|
4 |
|
5 |
full_text = open("state_of_the_union.txt", "r").read()
|
6 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
7 |
texts = text_splitter.split_text(full_text)
|
8 |
|
9 |
-
embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-
|
10 |
db = Chroma.from_texts(texts, embeddings)
|
11 |
retriever = db.as_retriever()
|
12 |
|
13 |
retrieved_docs = retriever.invoke(
|
14 |
-
|
15 |
)
|
16 |
-
|
|
|
|
|
|
|
|
1 |
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
2 |
from langchain.text_splitter import CharacterTextSplitter
|
3 |
from langchain.vectorstores import Chroma
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
+
text = st.'enter some text to start'
|
7 |
|
8 |
full_text = open("state_of_the_union.txt", "r").read()
|
9 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
10 |
texts = text_splitter.split_text(full_text)
|
11 |
|
12 |
+
embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-base")
|
13 |
db = Chroma.from_texts(texts, embeddings)
|
14 |
retriever = db.as_retriever()
|
15 |
|
16 |
retrieved_docs = retriever.invoke(
|
17 |
+
text
|
18 |
)
|
19 |
+
|
20 |
+
if text:
|
21 |
+
st.json(retrieved_docs)
|
22 |
+
|