Kyudan commited on
Commit
cf8f2e7
·
1 Parent(s): cf520f8
Files changed (3) hide show
  1. app.py +8 -0
  2. requirements.txt +2 -0
  3. translate.py +0 -0
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from langchain_community.embeddings import HuggingFaceEmbeddings
3
  from langchain_community.vectorstores import FAISS
4
  from openai import OpenAI
 
5
 
6
  YOUR_OPENAI_API_KEY = "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"
7
  # 임베딩 모델 로드
@@ -20,7 +21,14 @@ retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
20
 
21
 
22
  def chatbot(input_question):
 
 
23
  basic_docs = retriever.invoke(input_question)
 
 
 
 
 
24
  context = "\n".join([doc.page_content for doc in basic_docs])
25
 
26
  client = OpenAI(
 
2
  from langchain_community.embeddings import HuggingFaceEmbeddings
3
  from langchain_community.vectorstores import FAISS
4
  from openai import OpenAI
5
+ from translate import translate_ko_to_en
6
 
7
  YOUR_OPENAI_API_KEY = "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"
8
  # 임베딩 모델 로드
 
21
 
22
 
23
  def chatbot(input_question):
24
+ eng = translate_ko_to_en(input_question)
25
+ print(f"translated eng: {eng}")
26
  basic_docs = retriever.invoke(input_question)
27
+ eng_docs = retriever.invoke(eng)
28
+ basic_docs = list(set().union(eng_docs,basic_docs))
29
+
30
+ print(f"basic docs: {basic_docs}")
31
+
32
  context = "\n".join([doc.page_content for doc in basic_docs])
33
 
34
  client = OpenAI(
requirements.txt CHANGED
@@ -4,3 +4,5 @@ openai==1.58.1
4
  gradio
5
  sentence-transformers
6
  faiss-cpu
 
 
 
4
  gradio
5
  sentence-transformers
6
  faiss-cpu
7
+ transformers
8
+ sentencepiece
translate.py ADDED
File without changes