Add application file
Browse files- app.py +49 -25
- app_rag.py +128 -0
- requirements.txt +1 -1
app.py
CHANGED
@@ -470,13 +470,13 @@ class AutoRAGChatApp:
|
|
470 |
except Exception as e:
|
471 |
return f"์บ์ ์ด๊ธฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
472 |
|
473 |
-
def process_query(self, query: str, chat_history: List[
|
474 |
"""
|
475 |
์ฌ์ฉ์ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ
|
476 |
|
477 |
Args:
|
478 |
query: ์ฌ์ฉ์ ์ง๋ฌธ
|
479 |
-
chat_history: ๋ํ ๊ธฐ๋ก
|
480 |
|
481 |
Returns:
|
482 |
์๋ต ๋ฐ ์
๋ฐ์ดํธ๋ ๋ํ ๊ธฐ๋ก
|
@@ -484,37 +484,54 @@ class AutoRAGChatApp:
|
|
484 |
if not query: # ๋น์ด์๋ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ
|
485 |
return "", chat_history
|
486 |
|
487 |
-
if not self.is_initialized:
|
|
|
488 |
response = "๋ฌธ์ ๋ก๋๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค. ์๋ ๋ก๋๋ฅผ ์๋ํฉ๋๋ค."
|
489 |
-
chat_history
|
|
|
490 |
|
491 |
# ์๋ ๋ก๋ ์๋
|
492 |
try:
|
493 |
-
self.auto_process_documents()
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
|
|
|
|
498 |
except Exception as e:
|
499 |
response = f"๋ฌธ์ ๋ก๋ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
500 |
-
chat_history
|
501 |
-
|
|
|
|
|
|
|
502 |
|
503 |
try:
|
504 |
# RAG ์ฒด์ธ ์คํ ๋ฐ ์๋ต ์์ฑ
|
505 |
start_time = time.time()
|
|
|
506 |
response = self.rag_chain.run(query)
|
507 |
end_time = time.time()
|
508 |
|
509 |
query_time = end_time - start_time
|
510 |
print(f"์ฟผ๋ฆฌ ์ฒ๋ฆฌ ์๊ฐ: {query_time:.2f}์ด")
|
|
|
511 |
|
512 |
-
|
513 |
-
|
|
|
|
|
514 |
except Exception as e:
|
515 |
error_msg = f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
518 |
|
519 |
def process_voice_query(self, audio, chat_history: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
|
520 |
"""
|
@@ -579,7 +596,8 @@ class AutoRAGChatApp:
|
|
579 |
if not self.is_initialized or self.rag_chain is None:
|
580 |
print("์์ฑ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์ ๋ก๋ ์ด๊ธฐํ๊ฐ ํ์ํฉ๋๋ค.")
|
581 |
response = "๋ฌธ์ ๋ก๋๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค. ์๋ ๋ก๋๋ฅผ ์๋ํฉ๋๋ค."
|
582 |
-
chat_history
|
|
|
583 |
|
584 |
# ์๋ ๋ก๋ ์๋
|
585 |
try:
|
@@ -588,12 +606,14 @@ class AutoRAGChatApp:
|
|
588 |
|
589 |
if not self.is_initialized or self.rag_chain is None:
|
590 |
response = f"๋ฌธ์๋ฅผ ๋ก๋ํ ์ ์์ต๋๋ค. 'documents' ํด๋์ PDF ํ์ผ์ด ์๋์ง ํ์ธํ์ธ์.\n์ค๋ฅ ์ ๋ณด: {init_result}"
|
591 |
-
chat_history
|
592 |
-
|
|
|
593 |
except Exception as e:
|
594 |
response = f"๋ฌธ์ ๋ก๋ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
595 |
-
chat_history
|
596 |
-
|
|
|
597 |
else:
|
598 |
print("์์ฑ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์๊ฐ ์ด๋ฏธ ๋ก๋๋์ด ์์ต๋๋ค.")
|
599 |
|
@@ -608,15 +628,19 @@ class AutoRAGChatApp:
|
|
608 |
print(f"์ฟผ๋ฆฌ ์ฒ๋ฆฌ ์๊ฐ: {query_time:.2f}์ด")
|
609 |
print(f"์๋ต: {response[:100]}..." if len(response) > 100 else f"์๋ต: {response}")
|
610 |
|
611 |
-
|
612 |
-
|
|
|
|
|
613 |
except Exception as e:
|
614 |
error_msg = f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
615 |
print(f"RAG ์ฒด์ธ ์คํ ์ค ์ค๋ฅ: {error_msg}")
|
616 |
import traceback
|
617 |
traceback.print_exc()
|
618 |
-
|
619 |
-
|
|
|
|
|
620 |
|
621 |
except Exception as e:
|
622 |
error_msg = f"์์ฑ ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
@@ -736,7 +760,7 @@ class AutoRAGChatApp:
|
|
736 |
|
737 |
# ๋ํ ์ด๊ธฐํ ๋ฒํผ
|
738 |
clear_chat_button.click(
|
739 |
-
fn=lambda: [],
|
740 |
outputs=[chatbot]
|
741 |
)
|
742 |
|
|
|
470 |
except Exception as e:
|
471 |
return f"์บ์ ์ด๊ธฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
472 |
|
473 |
+
def process_query(self, query: str, chat_history: List[List[str]]) -> Tuple[str, List[List[str]]]:
|
474 |
"""
|
475 |
์ฌ์ฉ์ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ
|
476 |
|
477 |
Args:
|
478 |
query: ์ฌ์ฉ์ ์ง๋ฌธ
|
479 |
+
chat_history: ๋ํ ๊ธฐ๋ก (๋ฆฌ์คํธ ํ์)
|
480 |
|
481 |
Returns:
|
482 |
์๋ต ๋ฐ ์
๋ฐ์ดํธ๋ ๋ํ ๊ธฐ๋ก
|
|
|
484 |
if not query: # ๋น์ด์๋ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ
|
485 |
return "", chat_history
|
486 |
|
487 |
+
if not self.is_initialized or self.rag_chain is None:
|
488 |
+
print("ํ
์คํธ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์ ๋ก๋ ์ด๊ธฐํ๊ฐ ํ์ํฉ๋๋ค.")
|
489 |
response = "๋ฌธ์ ๋ก๋๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค. ์๋ ๋ก๋๋ฅผ ์๋ํฉ๋๋ค."
|
490 |
+
new_history = list(chat_history)
|
491 |
+
new_history.append([query, response])
|
492 |
|
493 |
# ์๋ ๋ก๋ ์๋
|
494 |
try:
|
495 |
+
init_result = self.auto_process_documents()
|
496 |
+
print(f"[DEBUG] ์๋ ๋ก๋ ํ is_initialized = {self.is_initialized}, RAG ์ฒด์ธ ์กด์ฌ = {self.rag_chain is not None}")
|
497 |
+
|
498 |
+
if not self.is_initialized or self.rag_chain is None:
|
499 |
+
response = f"๋ฌธ์๋ฅผ ๋ก๋ํ ์ ์์ต๋๋ค. 'documents' ํด๋์ PDF ํ์ผ์ด ์๋์ง ํ์ธํ์ธ์.\n์ค๋ฅ ์ ๋ณด: {init_result}"
|
500 |
+
new_history = list(chat_history)
|
501 |
+
new_history.append([query, response])
|
502 |
+
return "", new_history
|
503 |
except Exception as e:
|
504 |
response = f"๋ฌธ์ ๋ก๋ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
505 |
+
new_history = list(chat_history)
|
506 |
+
new_history.append([query, response])
|
507 |
+
return "", new_history
|
508 |
+
else:
|
509 |
+
print("ํ
์คํธ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์๊ฐ ์ด๋ฏธ ๋ก๋๋์ด ์์ต๋๋ค.")
|
510 |
|
511 |
try:
|
512 |
# RAG ์ฒด์ธ ์คํ ๋ฐ ์๋ต ์์ฑ
|
513 |
start_time = time.time()
|
514 |
+
print(f"RAG ์ฒด์ธ ์คํ ์ค: ์ฟผ๋ฆฌ = '{query}'")
|
515 |
response = self.rag_chain.run(query)
|
516 |
end_time = time.time()
|
517 |
|
518 |
query_time = end_time - start_time
|
519 |
print(f"์ฟผ๋ฆฌ ์ฒ๋ฆฌ ์๊ฐ: {query_time:.2f}์ด")
|
520 |
+
print(f"์๋ต: {response[:100]}..." if len(response) > 100 else f"์๋ต: {response}")
|
521 |
|
522 |
+
# ๋ฉ์์ง ํ์์ ๋ง๊ฒ ์ถ๊ฐ
|
523 |
+
new_history = list(chat_history)
|
524 |
+
new_history.append([query, response])
|
525 |
+
return "", new_history
|
526 |
except Exception as e:
|
527 |
error_msg = f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
528 |
+
print(f"RAG ์ฒด์ธ ์คํ ์ค ์ค๋ฅ: {error_msg}")
|
529 |
+
import traceback
|
530 |
+
traceback.print_exc()
|
531 |
+
|
532 |
+
new_history = list(chat_history)
|
533 |
+
new_history.append([query, error_msg])
|
534 |
+
return "", new_history
|
535 |
|
536 |
def process_voice_query(self, audio, chat_history: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
|
537 |
"""
|
|
|
596 |
if not self.is_initialized or self.rag_chain is None:
|
597 |
print("์์ฑ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์ ๋ก๋ ์ด๊ธฐํ๊ฐ ํ์ํฉ๋๋ค.")
|
598 |
response = "๋ฌธ์ ๋ก๋๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค. ์๋ ๋ก๋๋ฅผ ์๋ํฉ๋๋ค."
|
599 |
+
new_history = list(chat_history)
|
600 |
+
new_history.append([query, response])
|
601 |
|
602 |
# ์๋ ๋ก๋ ์๋
|
603 |
try:
|
|
|
606 |
|
607 |
if not self.is_initialized or self.rag_chain is None:
|
608 |
response = f"๋ฌธ์๋ฅผ ๋ก๋ํ ์ ์์ต๋๋ค. 'documents' ํด๋์ PDF ํ์ผ์ด ์๋์ง ํ์ธํ์ธ์.\n์ค๋ฅ ์ ๋ณด: {init_result}"
|
609 |
+
new_history = list(chat_history)
|
610 |
+
new_history.append([query, response])
|
611 |
+
return new_history
|
612 |
except Exception as e:
|
613 |
response = f"๋ฌธ์ ๋ก๋ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
614 |
+
new_history = list(chat_history)
|
615 |
+
new_history.append([query, response])
|
616 |
+
return new_history
|
617 |
else:
|
618 |
print("์์ฑ ์ฟผ๋ฆฌ ์ฒ๋ฆฌ: ๋ฌธ์๊ฐ ์ด๋ฏธ ๋ก๋๋์ด ์์ต๋๋ค.")
|
619 |
|
|
|
628 |
print(f"์ฟผ๋ฆฌ ์ฒ๋ฆฌ ์๊ฐ: {query_time:.2f}์ด")
|
629 |
print(f"์๋ต: {response[:100]}..." if len(response) > 100 else f"์๋ต: {response}")
|
630 |
|
631 |
+
# ๋ฉ์์ง ํ์์ ๋ง๊ฒ ์ถ๊ฐ
|
632 |
+
new_history = list(chat_history) # ๊ธฐ์กด ๋ฆฌ์คํธ๋ฅผ ๋ณต์ฌ
|
633 |
+
new_history.append([query, response]) # ๋ฆฌ์คํธ ํ์์ผ๋ก ์ถ๊ฐ
|
634 |
+
return new_history
|
635 |
except Exception as e:
|
636 |
error_msg = f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
637 |
print(f"RAG ์ฒด์ธ ์คํ ์ค ์ค๋ฅ: {error_msg}")
|
638 |
import traceback
|
639 |
traceback.print_exc()
|
640 |
+
# ๋ฉ์์ง ํ์์ ๋ง๊ฒ ์ถ๊ฐ
|
641 |
+
new_history = list(chat_history) # ๊ธฐ์กด ๋ฆฌ์คํธ๋ฅผ ๋ณต์ฌ
|
642 |
+
new_history.append([query, error_msg]) # ๋ฆฌ์คํธ ํ์์ผ๋ก ์ถ๊ฐ
|
643 |
+
return new_history
|
644 |
|
645 |
except Exception as e:
|
646 |
error_msg = f"์์ฑ ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
|
|
760 |
|
761 |
# ๋ํ ์ด๊ธฐํ ๋ฒํผ
|
762 |
clear_chat_button.click(
|
763 |
+
fn=lambda: [], # ๋น ๋ฆฌ์คํธ ๋ฐํ
|
764 |
outputs=[chatbot]
|
765 |
)
|
766 |
|
app_rag.py
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
์ฑ์ ๋ด์ฅ๋ ๊ฐ๋จํ RAG ์ฒด์ธ ๊ตฌํ
|
3 |
+
"""
|
4 |
+
from typing import List, Dict, Any, Optional
|
5 |
+
import os
|
6 |
+
from config import OPENAI_API_KEY, LLM_MODEL, USE_OPENAI, TOP_K_RETRIEVAL
|
7 |
+
|
8 |
+
# ์์ ํ ์ํฌํธ
|
9 |
+
try:
|
10 |
+
from langchain_openai import ChatOpenAI
|
11 |
+
from langchain.prompts import PromptTemplate
|
12 |
+
from langchain_core.output_parsers import StrOutputParser
|
13 |
+
from langchain_core.runnables import RunnablePassthrough
|
14 |
+
LANGCHAIN_IMPORTS_AVAILABLE = True
|
15 |
+
except ImportError:
|
16 |
+
print("[APP_RAG] langchain ๊ด๋ จ ํจํค์ง๋ฅผ ๋ก๋ํ ์ ์์ต๋๋ค.")
|
17 |
+
LANGCHAIN_IMPORTS_AVAILABLE = False
|
18 |
+
|
19 |
+
class SimpleRAGChain:
|
20 |
+
"""
|
21 |
+
๊ฐ๋จํ RAG ์ฒด์ธ ๊ตฌํ (์ฑ์ ๋ด์ฅ)
|
22 |
+
"""
|
23 |
+
def __init__(self, vector_store):
|
24 |
+
"""๊ฐ๋จํ RAG ์ฒด์ธ ์ด๊ธฐํ"""
|
25 |
+
print("[APP_RAG] ๊ฐ๋จํ RAG ์ฒด์ธ ์ด๊ธฐํ ์ค...")
|
26 |
+
self.vector_store = vector_store
|
27 |
+
|
28 |
+
if not LANGCHAIN_IMPORTS_AVAILABLE:
|
29 |
+
print("[APP_RAG] langchain ํจํค์ง๋ฅผ ์ฐพ์ ์ ์์ด RAG ์ฒด์ธ์ ์ด๊ธฐํํ ์ ์์ต๋๋ค.")
|
30 |
+
raise ImportError("RAG ์ฒด์ธ ์ด๊ธฐํ์ ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ค์น๋์ง ์์์ต๋๋ค.")
|
31 |
+
|
32 |
+
# API ํค ํ์ธ
|
33 |
+
if not OPENAI_API_KEY and USE_OPENAI:
|
34 |
+
print("[APP_RAG] ๊ฒฝ๊ณ : OpenAI API ํค๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
35 |
+
raise ValueError("OpenAI API ํค๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
36 |
+
|
37 |
+
try:
|
38 |
+
# LLM ์ด๊ธฐํ
|
39 |
+
if USE_OPENAI:
|
40 |
+
self.llm = ChatOpenAI(
|
41 |
+
model_name=LLM_MODEL,
|
42 |
+
temperature=0.2,
|
43 |
+
api_key=OPENAI_API_KEY,
|
44 |
+
)
|
45 |
+
print(f"[APP_RAG] OpenAI ๋ชจ๋ธ ์ด๊ธฐํ: {LLM_MODEL}")
|
46 |
+
else:
|
47 |
+
try:
|
48 |
+
# Ollama ์ฌ์ฉ ์๋
|
49 |
+
from langchain_community.chat_models import ChatOllama
|
50 |
+
from config import OLLAMA_HOST
|
51 |
+
|
52 |
+
self.llm = ChatOllama(
|
53 |
+
model=LLM_MODEL,
|
54 |
+
temperature=0.2,
|
55 |
+
base_url=OLLAMA_HOST,
|
56 |
+
)
|
57 |
+
print(f"[APP_RAG] Ollama ๋ชจ๋ธ ์ด๊ธฐํ: {LLM_MODEL}")
|
58 |
+
except ImportError:
|
59 |
+
# Ollama ๊ฐ์ ธ์ค๊ธฐ ์คํจ ์ OpenAI ์ฌ์ฉ
|
60 |
+
self.llm = ChatOpenAI(
|
61 |
+
model_name="gpt-3.5-turbo",
|
62 |
+
temperature=0.2,
|
63 |
+
api_key=OPENAI_API_KEY,
|
64 |
+
)
|
65 |
+
print("[APP_RAG] Ollama๋ฅผ ์ฌ์ฉํ ์ ์์ด OpenAI๋ก ๋์ฒดํฉ๋๋ค.")
|
66 |
+
|
67 |
+
# ํ๋กฌํํธ ํ
ํ๋ฆฟ
|
68 |
+
template = """
|
69 |
+
๋ค์ ์ ๋ณด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ง๋ฌธ์ ์ ํํ๊ฒ ๋ต๋ณํด์ฃผ์ธ์.
|
70 |
+
|
71 |
+
์ง๋ฌธ: {question}
|
72 |
+
|
73 |
+
์ฐธ๊ณ ์ ๋ณด:
|
74 |
+
{context}
|
75 |
+
|
76 |
+
์ฐธ๊ณ ์ ๋ณด์ ๋ต์ด ์๋ ๊ฒฝ์ฐ "์ ๊ณต๋ ๋ฌธ์์์ ํด๋น ์ ๋ณด๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค."๋ผ๊ณ ๋ต๋ณํ์ธ์.
|
77 |
+
๋ต๋ณ์ ์ ํํ๊ณ ๊ฐ๊ฒฐํ๊ฒ ์ ๊ณตํ๋, ์ฐธ๊ณ ์ ๋ณด์์ ๊ทผ๊ฑฐ๋ฅผ ์ฐพ์ ์ค๋ช
ํด์ฃผ์ธ์.
|
78 |
+
์ฐธ๊ณ ์ ๋ณด์ ์ถ์ฒ๋ ํจ๊ป ์๋ ค์ฃผ์ธ์.
|
79 |
+
"""
|
80 |
+
|
81 |
+
self.prompt = PromptTemplate.from_template(template)
|
82 |
+
|
83 |
+
# ์ฒด์ธ ๊ตฌ์ฑ
|
84 |
+
self.chain = (
|
85 |
+
{"context": self._retrieve, "question": RunnablePassthrough()}
|
86 |
+
| self.prompt
|
87 |
+
| self.llm
|
88 |
+
| StrOutputParser()
|
89 |
+
)
|
90 |
+
print("[APP_RAG] RAG ์ฒด์ธ ์ด๊ธฐํ ์๋ฃ")
|
91 |
+
except Exception as e:
|
92 |
+
print(f"[APP_RAG] RAG ์ฒด์ธ ์ด๊ธฐํ ์คํจ: {e}")
|
93 |
+
import traceback
|
94 |
+
traceback.print_exc()
|
95 |
+
raise
|
96 |
+
|
97 |
+
def _retrieve(self, query):
|
98 |
+
"""๋ฌธ์ ๊ฒ์"""
|
99 |
+
try:
|
100 |
+
docs = self.vector_store.similarity_search(query, k=TOP_K_RETRIEVAL)
|
101 |
+
|
102 |
+
# ๊ฒ์ ๊ฒฐ๊ณผ ์ปจํ
์คํธ ๊ตฌ์ฑ
|
103 |
+
context_parts = []
|
104 |
+
for i, doc in enumerate(docs, 1):
|
105 |
+
source = doc.metadata.get("source", "์ ์ ์๋ ์ถ์ฒ")
|
106 |
+
page = doc.metadata.get("page", "")
|
107 |
+
source_info = f"{source}"
|
108 |
+
if page:
|
109 |
+
source_info += f" (ํ์ด์ง: {page})"
|
110 |
+
|
111 |
+
context_parts.append(f"[์ฐธ๊ณ ์๋ฃ {i}] - ์ถ์ฒ: {source_info}\n{doc.page_content}\n")
|
112 |
+
|
113 |
+
return "\n".join(context_parts)
|
114 |
+
except Exception as e:
|
115 |
+
print(f"[APP_RAG] ๊ฒ์ ์ค ์ค๋ฅ: {e}")
|
116 |
+
import traceback
|
117 |
+
traceback.print_exc()
|
118 |
+
return "๋ฌธ์ ๊ฒ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค."
|
119 |
+
|
120 |
+
def run(self, query):
|
121 |
+
"""์ฟผ๋ฆฌ ์ฒ๋ฆฌ"""
|
122 |
+
try:
|
123 |
+
return self.chain.invoke(query)
|
124 |
+
except Exception as e:
|
125 |
+
print(f"[APP_RAG] ์คํ ์ค ์ค๋ฅ: {e}")
|
126 |
+
import traceback
|
127 |
+
traceback.print_exc()
|
128 |
+
return f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
langchain>=0.1.0
|
2 |
langchain-community>=0.0.10
|
3 |
langchain-huggingface>=0.0.1
|
|
|
4 |
sentence-transformers>=2.2.2
|
5 |
faiss-cpu>=1.7.4
|
6 |
pypdf>=3.15.1
|
@@ -8,7 +9,6 @@ gradio>=4.0.0
|
|
8 |
python-dotenv>=1.0.0
|
9 |
torch>=2.0.0
|
10 |
transformers>=4.34.0
|
11 |
-
langchain-openai>=0.0.2
|
12 |
openai>=1.0.0
|
13 |
docling>=0.1.3
|
14 |
requests>=2.28.0
|
|
|
1 |
langchain>=0.1.0
|
2 |
langchain-community>=0.0.10
|
3 |
langchain-huggingface>=0.0.1
|
4 |
+
langchain-openai>=0.0.2
|
5 |
sentence-transformers>=2.2.2
|
6 |
faiss-cpu>=1.7.4
|
7 |
pypdf>=3.15.1
|
|
|
9 |
python-dotenv>=1.0.0
|
10 |
torch>=2.0.0
|
11 |
transformers>=4.34.0
|
|
|
12 |
openai>=1.0.0
|
13 |
docling>=0.1.3
|
14 |
requests>=2.28.0
|