peterpeter8585 commited on
Commit
5599951
Β·
verified Β·
1 Parent(s): 3ff3b68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -15
app.py CHANGED
@@ -207,24 +207,26 @@ class GitHubModelLLM(LLM):
207
  # ──────────────────────────────
208
  import requests
209
  from datetime import datetime as dt1
210
- def get_current_time(timezone='Asia/Seoul'):
211
- url = f"https://timeapi.io/api/Time/current/zone?timeZone={timezone}"
 
 
 
 
 
 
 
 
212
  try:
213
- resp = requests.get(url)
214
  resp.raise_for_status()
215
- data = resp.json()
216
-
217
- # APIμ—μ„œ μ‹œκ°„ λ¬Έμžμ—΄ μΆ”μΆœ
218
- datetime_str = data.get("dateTime") # 예: "2025-10-23T19:42:58.1234567"
219
- dt = dt1.fromisoformat(datetime_str)
220
-
221
- # 보기 쒋은 ν˜•μ‹μœΌλ‘œ λ³€ν™˜
222
- formatted = dt.strftime("%Y-%m-%d %H:%M:%S")
223
- print(f"ν˜„μž¬ μ‹œκ°„ ({timezone}): {formatted}")
224
- return formatted
225
-
226
  except Exception as e:
227
- print("API 호좜 λ˜λŠ” νŒŒμ‹± 였λ₯˜:", e)
228
  return e
229
 
230
  tools = load_tools(["ddg-search", "llm-math","arxiv"], llm=llm,allow_dangerous_tools=True)
 
207
  # ──────────────────────────────
208
  import requests
209
  from datetime import datetime as dt1
210
+ import requests
211
+ from datetime import datetime as dt1, timezone, timedelta
212
+
213
+ def get_current_time() -> datetime:
214
+ """
215
+ ν˜„μž¬ ν•œκ΅­ ν‘œμ€€μ‹œ(Asia/Seoul)λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
216
+ μ‚¬μš©ν•˜λŠ” API: current-time JSON API (https://script.google.com/macros/s/…)
217
+ μ‹€νŒ¨ μ‹œ μ˜ˆμ™Έ λ°œμƒ.
218
+ """
219
+ url = "https://script.google.com/macros/s/AKfycbyd5AcbAnWi2Yn0xhFRbyzS4qMq1VucMVgVvhul5XqS9HkAyJY/exec?tz=Asia/Seoul"
220
  try:
221
+ resp = requests.get(url, timeout=5)
222
  resp.raise_for_status()
223
+ j = resp.json()
224
+ # μ˜ˆμƒλœ ν•„λ“œ: e.g. {"timezone":"Asia/Seoul","datetime":"2025-10-23T13:45:30+09:00", ...}
225
+ if "datetime" not in j:
226
+ raise RuntimeError(f"응닡에 datetime ν•„λ“œ μ—†μŒ: {j}")
227
+ dt = dt1.fromisoformat(j["datetime"])
228
+ return dt.isoformat() # 이미 +09:00 ν¬ν•¨λœ ν˜„μ§€μ‹œκ°„
 
 
 
 
 
229
  except Exception as e:
 
230
  return e
231
 
232
  tools = load_tools(["ddg-search", "llm-math","arxiv"], llm=llm,allow_dangerous_tools=True)