yongyeol commited on
Commit
3ea2291
Β·
verified Β·
1 Parent(s): 7858545

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -2,15 +2,20 @@
2
  import gradio as gr
3
  import requests
4
  from datetime import datetime
5
- from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
 
6
 
7
- # Load Google Gemma λͺ¨λΈ (2B)
8
- model_id = "google/gemma-2b-it"
9
- tokenizer = AutoTokenizer.from_pretrained(model_id)
10
- model = AutoModelForCausalLM.from_pretrained(model_id)
 
 
 
 
11
  generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
12
 
13
- # NEIS API
14
  NEIS_KEY = "a69e08342c8947b4a52cd72789a5ecaf"
15
  SCHOOL_INFO_URL = "https://open.neis.go.kr/hub/schoolInfo"
16
  SCHEDULE_URL = "https://open.neis.go.kr/hub/SchoolSchedule"
@@ -104,6 +109,6 @@ with gr.Interface(
104
  ],
105
  outputs=gr.Textbox(label="GPT의 응닡"),
106
  title="πŸ“… 학사일정 + GPT 챗봇 (Gemma 2B)",
107
- description="KoAlpaca λŒ€μ‹  Gemma λͺ¨λΈλ‘œ 학사일정 기반 챗봇을 μ‹€ν–‰ν•©λ‹ˆλ‹€."
108
  ) as app:
109
  app.launch()
 
2
  import gradio as gr
3
  import requests
4
  from datetime import datetime
5
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
6
+ import os
7
 
8
+ # βœ… Hugging Face token 인증 (ν•„μš”μ‹œ ν™˜κ²½λ³€μˆ˜ μ‚¬μš©)
9
+ from huggingface_hub import login
10
+ login(token=os.environ.get("HF_TOKEN"), new_session=False)
11
+
12
+ # βœ… Gemma λͺ¨λΈ λ‘œλ“œ (gated repo)
13
+ model_id = "google/gemma-2-2b-it"
14
+ tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
15
+ model = AutoModelForCausalLM.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
16
  generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
17
 
18
+ # βœ… NEIS API
19
  NEIS_KEY = "a69e08342c8947b4a52cd72789a5ecaf"
20
  SCHOOL_INFO_URL = "https://open.neis.go.kr/hub/schoolInfo"
21
  SCHEDULE_URL = "https://open.neis.go.kr/hub/SchoolSchedule"
 
109
  ],
110
  outputs=gr.Textbox(label="GPT의 응닡"),
111
  title="πŸ“… 학사일정 + GPT 챗봇 (Gemma 2B)",
112
+ description="Gemma λͺ¨λΈ 기반의 학사일정 μ±—λ΄‡μž…λ‹ˆλ‹€. 연도/월은 μƒλž΅ μ‹œ 였늘 κΈ°μ€€μœΌλ‘œ μ²˜λ¦¬λ©λ‹ˆλ‹€."
113
  ) as app:
114
  app.launch()