Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,11 @@ import numpy as np
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from groq import Groq
|
| 8 |
|
| 9 |
-
# ✅ 1.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
raise ValueError("GROQ_API_KEY 환경 변수가 설정되지 않았습니다.")
|
| 13 |
-
client = Groq(api_key=api_key)
|
| 14 |
|
| 15 |
-
# ✅ 2. PDF 파일 경로 리스트
|
| 16 |
pdf_paths = [
|
| 17 |
"pdfs/의왕단오축제 _ 의왕문화원.pdf",
|
| 18 |
"pdfs/성인 문화학교 _ 의왕문화원.pdf",
|
|
@@ -88,19 +86,25 @@ suggested_questions = [
|
|
| 88 |
|
| 89 |
# ✅ 9. Gradio UI 구성
|
| 90 |
with gr.Blocks() as demo:
|
| 91 |
-
gr.Markdown("#
|
| 92 |
-
gr.Markdown("
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
for q in suggested_questions:
|
| 102 |
-
gr.Button(q).click(fn=chatbot_interface, inputs=gr.Textbox(value=q), outputs=answer_box)
|
| 103 |
|
| 104 |
# ✅ 10. 앱 실행
|
| 105 |
if __name__ == "__main__":
|
| 106 |
-
demo.launch()
|
|
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from groq import Groq
|
| 8 |
|
| 9 |
+
# ✅ 1. Groq API 키 설정
|
| 10 |
+
os.environ["GROQ_API_KEY"] = "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"
|
| 11 |
+
client = Groq(api_key=os.environ["GROQ_API_KEY"])
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# ✅ 2. PDF 파일 경로 리스트 (pdfs 폴더 기준)
|
| 14 |
pdf_paths = [
|
| 15 |
"pdfs/의왕단오축제 _ 의왕문화원.pdf",
|
| 16 |
"pdfs/성인 문화학교 _ 의왕문화원.pdf",
|
|
|
|
| 86 |
|
| 87 |
# ✅ 9. Gradio UI 구성
|
| 88 |
with gr.Blocks() as demo:
|
| 89 |
+
gr.Markdown("# 📘 오아시스 문서 기반 문화 프로그램 챗봇 🤖 '뮤지스(Musesis)'")
|
| 90 |
+
gr.Markdown("질문을 입력하면 유사 문서를 검색해 답변해줍니다.")
|
| 91 |
|
| 92 |
+
with gr.Row():
|
| 93 |
+
question_box = gr.Textbox(placeholder="질문을 입력하세요", label="질문")
|
| 94 |
+
with gr.Row():
|
| 95 |
+
submit_btn = gr.Button("질문하기")
|
| 96 |
+
with gr.Row():
|
| 97 |
+
answer_box = gr.Textbox(label="답변", lines=10)
|
| 98 |
|
| 99 |
+
with gr.Row():
|
| 100 |
+
gr.Markdown("### 💡 추천 질문")
|
| 101 |
+
with gr.Column():
|
| 102 |
+
for q in suggested_questions:
|
| 103 |
+
btn = gr.Button(q)
|
| 104 |
+
btn.click(fn=chatbot_interface, inputs=gr.Textbox(value=q, visible=False), outputs=answer_box)
|
| 105 |
|
| 106 |
+
submit_btn.click(fn=chatbot_interface, inputs=question_box, outputs=answer_box)
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# ✅ 10. 앱 실행
|
| 109 |
if __name__ == "__main__":
|
| 110 |
+
demo.launch()
|