kim368882 commited on
Commit
e58b3a5
Β·
verified Β·
1 Parent(s): f5eb5d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
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 [data["choices"][0]["message"]["content"], get_famous_people(lunIljin)]
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()