kim368882 commited on
Commit
27ff44d
โ€ข
1 Parent(s): 412d5ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -126,6 +126,27 @@ def get_lunar_info(solYear, solMonth, solDay, solHour):
126
  return {"Error": "API ํ˜ธ์ถœ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."}, "์ •๋ณด ์—†์Œ", "<p>API ํ˜ธ์ถœ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.</p>"
127
 
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  def analyze_character(lunIljin, OPENAI_API_KEY):
130
  API_URL = "https://api.openai.com/v1/chat/completions"
131
  payload = {
@@ -146,7 +167,7 @@ def analyze_character(lunIljin, OPENAI_API_KEY):
146
  if response.status_code == 200:
147
  data = response.json()
148
  # ๋Œ€ํ™”ํ˜• API ์‘๋‹ต์—์„œ ์ ์ ˆํ•œ ๋ฉ”์‹œ์ง€ ์ถ”์ถœ
149
- return data["choices"][0]["message"]["content"]
150
  else:
151
  # ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€ ๊ฐœ์„ 
152
  return f"์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ƒํƒœ ์ฝ”๋“œ: {response.status_code}, ๋ฉ”์‹œ์ง€: {response.json().get('error', {}).get('message', 'Unknown error')}"
 
126
  return {"Error": "API ํ˜ธ์ถœ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."}, "์ •๋ณด ์—†์Œ", "<p>API ํ˜ธ์ถœ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.</p>"
127
 
128
 
129
+ # B ๋ฐ์ดํ„ฐ๋ฅผ ํ™œ์šฉํ•˜๋Š” ํ•จ์ˆ˜ ์ถ”๊ฐ€
130
+ def get_famous_people(lunIljin):
131
+ famous_people = {
132
+ "๊ฐ‘์ž": "๋ฐ•์ˆ˜์ฃผ[๋ชจ๋ธ], ์œˆํ„ฐ, ๋‹๋‹, ์ด์žฌ์šฉ, ๋นˆ์ง€๋…ธ, ๊น€์žฌํ™˜[์›Œ๋„ˆ์›], ์„ค์œค[์—”๋ฏน์Šค], ์Œ๋ฌธ์„, ์กฐ์กฐ",
133
+ "๊ฐ‘์ˆ ": "์•ˆ์†Œํฌ, ์žฅ๊ธฐํ•˜, ์†กํ•˜์˜[ํ”„๋ฏธ๋‚˜], ์ง€ํšจ[ํŠธ์™€], ๋‹ˆ์—˜, ์ผ€๋ผ ์—์ด์ฝ”[์•„๋”ฐ๋ง˜๋งˆ], ์ด์˜ณ์ด[์œ ํŠœ๋ฒ„], ์— ์”จ๋ชฝ, ๆ•… ์ด์†Œ๋ฃก",
134
+ "๊ฐ‘์‹ ": "๊น€๊ฒฝ์šฑ[๋‹ค๋‚˜์นด], ์ง€์ง€ ํ•˜๋””๋“œ, ๋กœ์ œ, ์˜ˆ์ง€[ITZY], ๋ฐ•์ง€ํ›„, ๋ฐ”๋กœ[๋น„ํฌ], ์„ค์•„[์šฐ์ฃผ์†Œ๋…€], ํ•œ์Šน์šฐ, ์ตœ์˜ˆ๋‚˜, ์กฐ์ง„์›…, ์œ ํ•ด์ง„, ํ™ฉ์ •๋ฏผ, ๋‹ค๋‹ˆ์—˜ ๋ž˜๋“œํด๋ฆฌํ”„[ํ•ด๋ฆฌํฌํ„ฐ], ์ตœ์†Œ๋ผ[๋ชจ๋ธ], ์ˆ˜์ƒค์ƒค[์œ ํŠœ๋ฒ„]",
135
+ "๊ฐ‘์˜ค": "์กฐ์ดํ˜„, ์ง„๊ตฌ, ์ด๊ธฐ๊ด‘, ๋ฏผ์•„, ์„คํ˜„, ํ…[NCT], ๊น€์ข…๋ฏผ, ์šฐ์›์žฌ, ๊ธฐ๋ฆฌ๋ณด์ด, ์–‘ํ™์›, ํ…Œ์Šฌ๋ผ, ํ›„๋ฃจ๋‹คํ…Œ ํ•˜๋ฃจ์ด์น˜[ํ•˜์ดํ]",
136
+ "๊ฐ‘์ง„": "ํ•ด๋ฆฐ[๋‰ด์ง„์Šค], ํ—ˆ์œค์ง„, ๋ฆฌ์ฆˆ[์•„์ด๋ธŒ], ํ•œ์„ ํ™”, ํƒœํ˜„[ํˆฌ๋ฐ”ํˆฌ], ์ง€์„ฑ[NCT], ๋ฐ•์žฌ๋ฒ”, ์†กํ˜œ๊ต, ๊น€์ •๋ฏธ[๊ฐ€์ˆ˜], ์•„๋ผ์นด์™€ ํžˆ๋กœ๋ฌด[๊ฐ•์ฒ ์˜ ์—ฐ๊ธˆ์ˆ ์‚ฌ]",
137
+ "๊ฐ‘์ธ": "๊น€์šฉ์ง€[๋ฐฐ์šฐ], ์นด์ฆˆํ•˜, ์—๋ฆญ,์ผ€๋นˆ[๋”๋ณด์ด์ฆˆ], ํœด๋‹์นด์ด[ํˆฌ๋ฐ”ํˆฌ], ๋น„๋‹ˆ, ์ง„, ์ด๊ด‘์ˆ˜, ๋ฐ•์‹ ํ˜œ, ํ”ผ์˜ค, ์— ๋งˆ[์Šค์šฐํŒŒ], ๋ฐฐ๋ฆฌ ํŽ˜ํผ[๋ฐฐ์šฐ], ์ฟ ๋ณด ํƒ€์ดํ† [๋ธ”๋ฆฌ์น˜], ๊น€๊ฐ€๋žŒ[ํƒˆํ‡ด], ๆ•… ์„ค๋ฆฌ",
138
+ "์„์ถ•": "์ƒˆ์†Œ๋…„, ๋‹ค๋‹ˆ์—˜[๋‰ด์ง„์Šค], ์‚ฌ์ฟ ๋ผ, ๊ณผ์ฒœ๊ฟ€์ˆ˜๋ฐ•[๋Œ„์„œ], ์ฃผํ—Œ[๋ชฌ์—‘], ์œค๋‘์ค€, ์†Œ์ง€์„ญ, ์‹ ์˜ˆ์€, ๊น€๋Œ€๋ช…, ์ง€๋‹ˆ[ํƒˆํ‡ด], ๋ฐ•ํ™”์š”๋น„, ์œ ์˜์ง„[์ž‘๊ณก๊ฐ€], ๆ•… ๋ฐ•๊ฒฝ๋ฆฌ[ํ† ์ง€ ์ž‘๊ฐ€]",
139
+ "์„ํ•ด": "๊น€์€์ˆ™[์ž‘๊ฐ€], ํ•˜๋น„์—๋ฅด ๋ฐ”๋ฅด๋Ž€, ์ˆ˜๋ฏผ[์Šคํ…Œ์ด์”จ], ๋ฒ”๊ทœ[ํˆฌ๋ฐ”ํˆฌ], ๋ฌธ์žฌ์ธ, ํ™์ค€ํ‘œ, ํ˜ธ๋‚ ๋‘, ์ œ์ดํ™‰, ์œ ์—ฐ์„, ํ•œ[์Šคํ‚ค์ฆˆ], ์ดํ†  ์ค€์ง€, ์ž„๋ผ๋ผ[์—”์กฐ์ด์ปคํ”Œ]",
140
+ "์„์œ ": "๊น€๋ฏผ๊ทœ[๋ฐฐ์šฐ], ๊น€๊ฑด์šฐ[๋”๊ธ€๋กœ๋ฆฌ], ์Šฌ๋ฆฌํ”ผ, ๊น€๋‚จ๊ธธ, ๊น€์œค์„, ์†ํฅ๋ฏผ, ์ด์žฌ๋ช…, ๋งˆ๋™์„, ์ง€ํ˜ธ์ง€๋ฐฉ์‹œ",
141
+ "์„๋ฏธ": "์‹ ์„ธ๊ฒฝ, ๋ธŒ๋ž˜๋“œ ํ”ผํŠธ, ๊ฐ€์„[์•„์ด๋ธŒ], ์•ˆ์ฒ ์ˆ˜, ์‚ฐ๋“ค[๋น„ํฌ], ์†์„ํฌ, ๋ท”, ์œค์•„, ํ•ด์ฐฌ[NCT], ๋ฆฌ์•ˆ[์Šค์šฐํŒŒ], ํšจ์ง„์ดˆ์ด[์Šค์šฐํŒŒ], ์ฐฝ๋นˆ[์Šคํ‚ค์ฆˆ], ์ด์ˆ˜๋งŒ, ์™•๊ฐ€์œ„, ์•„์˜ค์•ผ๋งˆ ๊ณ ์‡ผ[์ฝ”๋‚œ], ๆ•… ์œค์ •ํฌ[๋ฐฐ์šฐ]",
142
+ "์„์‚ฌ": "์ด์œ ๋ฏธ, ๊ถŒํ˜„๋นˆ, ๋ฐ•์„œ์ค€, GD, ์„œ์ธ๊ตญ, ๋ฐ•์„ฑ์›…, ์ƒ์—ฐ[๋”๋ณด์ด์ฆˆ], ์ธ„, ์ „์†Œ์—ฐ, ๋ฆฌ๋…ธ[์Šคํ‚ค์ฆˆ], ์ด์‹œ์•ผ๋งˆ ํ•˜์ง€๋ฉ”[์ง„๊ฒฉ์˜ ๊ฑฐ์ธ], ์‚ฐ๋ฒ”",
143
+ "์„๋ฌ˜": "๋ฌธ๊ทผ์˜, ๊ธฐ์šฐ์Œค, ํ™”์‚ฌ, ์—ผํ˜œ๋ž€, ๊ทœ์ง„[์—”๋ฏน์Šค], ํšจ์ •, ์žฅ๊ธฐ์šฉ, ์ง€์„ฑ, ์ด๊ทผ, ์กฐ์šฉํ•„, ๋ฆฌ์Œ, ๋ฃจํ•œ, ํƒ€์นดํ•˜์‹œ ๋ฃจ๋ฏธ์ฝ”[์ด๋ˆ„์•ผ์ƒค]",
144
+ "๋ณ‘์ธ": "์žฅํ˜„์Šน, ์†์„๊ตฌ, ๋ฐ•์ง€์›[ํ”„๋ฏธ๋‚˜], ๋ผ๋“œ๋ฎค์ง€์—„, ๊น€ํ•˜์˜จ, ์ดํ™๊ธฐ, ๋ฒ„๋ฒŒ์ง„ํŠธ, ํ˜œ๋ฆฌ, ์˜ค์€์˜, ๊ฐ•ํ˜•์šฑ, ๋ฐฑ์ข…์›, ์•„๋ผํ‚ค ํžˆ๋กœํžˆ์ฝ”[์ฃ ์ฃ ์˜ ๊ธฐ๋ฌ˜ํ•œ ๋ชจํ—˜], ๋ ˆ์˜ค์ œ์ด[์œ ํŠœ๋ฒ„], ํžˆํ‹€๋Ÿฌ",
145
+ "๋ณ‘์ž": "์‹ ์„ธํœ˜, ํ™์Šน์—ฐ[๋ฃจํŠธ,๋Œ„์„œ], ์ฃผ์šฐ์žฌ, ํ•„๋ฆญ์Šค[์Šคํ‚ค์ฆˆ], ์ง€ํ˜ธ, ๋ฐฑ์ง€์˜, ๊น€๋ณ‘๋งŒ, ์ด๋…ธ์šฐ์— ๋‹ค์ผ€ํžˆ์ฝ”[์Šฌ๋žจ๋ฉํฌ], ํ™ฉ์˜์กฐ, ํ’์ž",
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 = {
 
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')}"