hallu11 commited on
Commit
86363b5
·
verified ·
1 Parent(s): 210ba23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
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. 안전하게 Groq API 키 설정
10
- api_key = os.environ.get("GROQ_API_KEY")
11
- if not api_key:
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
- question_box = gr.Textbox(placeholder="질문을 입력하세요", label="질문")
95
- answer_box = gr.Textbox(label="답변", lines=10)
96
- submit_btn = gr.Button("질문하기")
 
 
 
97
 
98
- submit_btn.click(fn=chatbot_interface, inputs=question_box, outputs=answer_box)
 
 
 
 
 
99
 
100
- gr.Markdown("### 💡 추천 질문")
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()