Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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')}"
|