Spaces:
Running
Running
Kyudan
commited on
Commit
โข
2cc938b
1
Parent(s):
6335df2
buttons
Browse files
app.py
CHANGED
@@ -16,16 +16,20 @@ embedding_model = HuggingFaceEmbeddings(
|
|
16 |
# vector DB ๋ก๋๋
|
17 |
save_path = "./my_faiss_index"
|
18 |
vectorstore = FAISS.load_local(save_path, embedding_model,allow_dangerous_deserialization=True)
|
19 |
-
retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
|
20 |
|
21 |
|
22 |
|
23 |
-
def chatbot(input_question):
|
24 |
-
eng = translate_ko_to_en(input_question)
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
context = "\n".join([doc.page_content for doc in basic_docs])
|
31 |
|
@@ -57,5 +61,9 @@ def chatbot(input_question):
|
|
57 |
|
58 |
|
59 |
|
60 |
-
demo = gr.Interface(fn=chatbot,
|
|
|
|
|
|
|
|
|
61 |
demo.launch()
|
|
|
16 |
# vector DB ๋ก๋๋
|
17 |
save_path = "./my_faiss_index"
|
18 |
vectorstore = FAISS.load_local(save_path, embedding_model,allow_dangerous_deserialization=True)
|
|
|
19 |
|
20 |
|
21 |
|
|
|
|
|
22 |
|
23 |
+
def chatbot(input_question, eng_trans = True, num_ref = 3):
|
24 |
+
retriever = vectorstore.as_retriever(search_kwargs={"k": num_ref})
|
25 |
+
if eng_trans == False:
|
26 |
+
basic_docs = retriever.invoke(input_question)
|
27 |
+
else:
|
28 |
+
eng = translate_ko_to_en(input_question)
|
29 |
+
|
30 |
+
basic_docs = retriever.invoke(input_question)
|
31 |
+
eng_docs = retriever.invoke(eng)
|
32 |
+
basic_docs = basic_docs + eng_docs
|
33 |
|
34 |
context = "\n".join([doc.page_content for doc in basic_docs])
|
35 |
|
|
|
61 |
|
62 |
|
63 |
|
64 |
+
demo = gr.Interface(fn=chatbot,
|
65 |
+
inputs=[gr.Textbox(label="์ง๋ฌธ ์
๋ ฅ"), # ํ
์คํธ ์
๋ ฅ
|
66 |
+
gr.Checkbox(label="์์ด ๋ฒ์ญ ์ฌ์ฉ ์ฌ๋ถ", value=True), # ์ฒดํฌ๋ฐ์ค ์ถ๊ฐ
|
67 |
+
gr.Slider(1,5, value=3, step=1),
|
68 |
+
], outputs="text")
|
69 |
demo.launch()
|