Kyudan commited on
Commit
2cc938b
โ€ข
1 Parent(s): 6335df2
Files changed (1) hide show
  1. app.py +15 -7
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
- basic_docs = retriever.invoke(input_question)
27
- eng_docs = retriever.invoke(eng)
28
- basic_docs = basic_docs + eng_docs
 
 
 
 
 
 
 
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, inputs="text", outputs="text")
 
 
 
 
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()