Spaces:
Sleeping
Sleeping
Debug
Browse files
app.py
CHANGED
@@ -83,17 +83,17 @@ def generate(URL, query):
|
|
83 |
documents = loader.load()
|
84 |
except Exception as e:
|
85 |
return "Error getting reviews: " + str(e)
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
return qa.run(query)
|
98 |
|
99 |
|
@@ -113,5 +113,6 @@ gr.Interface(
|
|
113 |
outputs=gr.Textbox(label="Jawaban"),
|
114 |
title="RingkasUlas",
|
115 |
description="Bot percakapan yang bisa meringkas ulasan-ulasan produk di Tokopedia Indonesia (https://tokopedia.com/). Harap bersabar, bot ini dapat memakan waktu agak lama saat mengambil ulasan dari Tokopedia dan menyiapkan jawabannya.",
|
116 |
-
allow_flagging="never"
|
|
|
117 |
).launch()
|
|
|
83 |
documents = loader.load()
|
84 |
except Exception as e:
|
85 |
return "Error getting reviews: " + str(e)
|
86 |
+
else:
|
87 |
+
# Split text
|
88 |
+
text_splitter = RecursiveCharacterTextSplitter(
|
89 |
+
chunk_size=1000, chunk_overlap=50
|
90 |
+
)
|
91 |
+
docs = text_splitter.split_documents(documents)
|
92 |
+
cache_URL = URL
|
93 |
+
# Vector store
|
94 |
+
db = FAISS.from_documents(docs, embeddings)
|
95 |
+
# Chain to answer questions
|
96 |
+
qa = RetrievalQA.from_chain_type(llm=llm, retriever=db.as_retriever())
|
97 |
return qa.run(query)
|
98 |
|
99 |
|
|
|
113 |
outputs=gr.Textbox(label="Jawaban"),
|
114 |
title="RingkasUlas",
|
115 |
description="Bot percakapan yang bisa meringkas ulasan-ulasan produk di Tokopedia Indonesia (https://tokopedia.com/). Harap bersabar, bot ini dapat memakan waktu agak lama saat mengambil ulasan dari Tokopedia dan menyiapkan jawabannya.",
|
116 |
+
allow_flagging="never",
|
117 |
+
interpret_error=lambda e: str(e)
|
118 |
).launch()
|