Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -125,7 +125,6 @@ def get_lunar_info(solYear, solMonth, solDay, solHour):
|
|
125 |
else:
|
126 |
return {"Error": "API 호출에 실패했습니다."}, "정보 없음", "<p>API 호출에 실패했습니다.</p>"
|
127 |
|
128 |
-
|
129 |
# B 데이터를 활용하는 함수 추가
|
130 |
def get_famous_people(lunIljin):
|
131 |
famous_people = {
|
@@ -146,7 +145,6 @@ def get_famous_people(lunIljin):
|
|
146 |
}
|
147 |
return famous_people.get(lunIljin, "해당 일주에 대한 유명인 정보가 없습니다.")
|
148 |
|
149 |
-
|
150 |
def analyze_character(lunIljin, OPENAI_API_KEY):
|
151 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
152 |
payload = {
|
@@ -166,13 +164,12 @@ def analyze_character(lunIljin, OPENAI_API_KEY):
|
|
166 |
response = requests.post(API_URL, headers=headers, json=payload)
|
167 |
if response.status_code == 200:
|
168 |
data = response.json()
|
169 |
-
# 대화형 API 응답에서 적절한 메시지 추출
|
170 |
-
return
|
171 |
else:
|
172 |
# 오류 메시지 개선
|
173 |
-
return f"오류가 발생했습니다. 상태 코드: {response.status_code}, 메시지: {response.json().get('error', {}).get('message', 'Unknown error')}"
|
174 |
|
175 |
-
|
176 |
|
177 |
# 사주 분석 데이터 예시 (간소화된 버전)
|
178 |
사주_데이터 = {
|
@@ -252,9 +249,6 @@ def 사주_분석(년주, 월주, 일주, 시주):
|
|
252 |
return html_result
|
253 |
|
254 |
|
255 |
-
def analyze_character(lunIljin_state, OPENAI_API_KEY):
|
256 |
-
# 여기에 성격과 특징을 분석하는 함수의 내용을 구현하세요.
|
257 |
-
pass
|
258 |
with gr.Blocks() as demo:
|
259 |
with gr.Tab("AI 사주 운세 분석"):
|
260 |
solYear = gr.Textbox(label="생년(예: 1990)")
|
@@ -280,9 +274,7 @@ with gr.Blocks() as demo:
|
|
280 |
|
281 |
analyze_button = gr.Button("분석하기")
|
282 |
analyze_button.click(fn=analyze_character, inputs=[lunIljin_state, OPENAI_API_KEY_input], outputs=[character_output, celebrity_output])
|
283 |
-
|
284 |
-
# 유명인 분석을 같은 탭에 추가
|
285 |
-
|
286 |
|
|
|
287 |
|
288 |
demo.launch()
|
|
|
125 |
else:
|
126 |
return {"Error": "API 호출에 실패했습니다."}, "정보 없음", "<p>API 호출에 실패했습니다.</p>"
|
127 |
|
|
|
128 |
# B 데이터를 활용하는 함수 추가
|
129 |
def get_famous_people(lunIljin):
|
130 |
famous_people = {
|
|
|
145 |
}
|
146 |
return famous_people.get(lunIljin, "해당 일주에 대한 유명인 정보가 없습니다.")
|
147 |
|
|
|
148 |
def analyze_character(lunIljin, OPENAI_API_KEY):
|
149 |
API_URL = "https://api.openai.com/v1/chat/completions"
|
150 |
payload = {
|
|
|
164 |
response = requests.post(API_URL, headers=headers, json=payload)
|
165 |
if response.status_code == 200:
|
166 |
data = response.json()
|
167 |
+
# 대화형 API 응답에서 적절한 메시지 추출 및 유명인 이름 반환
|
168 |
+
return data["choices"][0]["message"]["content"], get_famous_people(lunIljin)
|
169 |
else:
|
170 |
# 오류 메시지 개선
|
171 |
+
return f"오류가 발생했습니다. 상태 코드: {response.status_code}, 메시지: {response.json().get('error', {}).get('message', 'Unknown error')}", ""
|
172 |
|
|
|
173 |
|
174 |
# 사주 분석 데이터 예시 (간소화된 버전)
|
175 |
사주_데이터 = {
|
|
|
249 |
return html_result
|
250 |
|
251 |
|
|
|
|
|
|
|
252 |
with gr.Blocks() as demo:
|
253 |
with gr.Tab("AI 사주 운세 분석"):
|
254 |
solYear = gr.Textbox(label="생년(예: 1990)")
|
|
|
274 |
|
275 |
analyze_button = gr.Button("분석하기")
|
276 |
analyze_button.click(fn=analyze_character, inputs=[lunIljin_state, OPENAI_API_KEY_input], outputs=[character_output, celebrity_output])
|
|
|
|
|
|
|
277 |
|
278 |
+
|
279 |
|
280 |
demo.launch()
|