Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -198,19 +198,21 @@ def respond_gemini_qna(
|
|
198 |
"""
|
199 |
try:
|
200 |
import google.generativeai as genai
|
201 |
-
from google.generativeai import types
|
202 |
except ModuleNotFoundError:
|
203 |
return ("오류가 발생했습니다: 'google-generativeai' 모듈을 찾을 수 없습니다. "
|
204 |
-
"해결 방법: 'pip install google-generativeai'를 실행하여 설치해주세요.")
|
205 |
|
206 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
207 |
if not gemini_api_key:
|
208 |
return "Gemini API 토큰이 필요합니다."
|
209 |
|
210 |
-
|
|
|
|
|
211 |
prompt = f"{system_message}\n\n{question}"
|
|
|
212 |
try:
|
213 |
-
response =
|
214 |
model=model_id,
|
215 |
contents=[prompt]
|
216 |
)
|
|
|
198 |
"""
|
199 |
try:
|
200 |
import google.generativeai as genai
|
|
|
201 |
except ModuleNotFoundError:
|
202 |
return ("오류가 발생했습니다: 'google-generativeai' 모듈을 찾을 수 없습니다. "
|
203 |
+
"해결 방법: 'pip install google-generativeai' 를 실행하여 설치해주세요.")
|
204 |
|
205 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
206 |
if not gemini_api_key:
|
207 |
return "Gemini API 토큰이 필요합니다."
|
208 |
|
209 |
+
# API 키 설정
|
210 |
+
genai.configure(api_key=gemini_api_key)
|
211 |
+
|
212 |
prompt = f"{system_message}\n\n{question}"
|
213 |
+
|
214 |
try:
|
215 |
+
response = genai.models.generate_content(
|
216 |
model=model_id,
|
217 |
contents=[prompt]
|
218 |
)
|