fantaxy commited on
Commit
04e9db1
ยท
verified ยท
1 Parent(s): a5a2931

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -2,7 +2,10 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
  from gradio_client import Client # ์ด๋ฏธ์ง€ ์ƒ์„ฑ API ํด๋ผ์ด์–ธํŠธ
 
5
 
 
 
6
  # ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ Hugging Face API ํ† ํฐ์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
7
  hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
8
 
@@ -46,9 +49,18 @@ def respond(
46
  return result['url']
47
  else:
48
  return "์ด๋ฏธ์ง€ ์ƒ์„ฑ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."
 
 
 
 
 
 
 
 
49
  except Exception as e:
 
50
  return f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
51
-
52
  theme = "Nymbo/Nymbo_Theme"
53
  css = """
54
  footer {
 
2
  from huggingface_hub import InferenceClient
3
  import os
4
  from gradio_client import Client # ์ด๋ฏธ์ง€ ์ƒ์„ฑ API ํด๋ผ์ด์–ธํŠธ
5
+ import logging
6
 
7
+ # ๋กœ๊น… ์„ค์ •
8
+ logging.basicConfig(level=logging.INFO)
9
  # ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ Hugging Face API ํ† ํฐ์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.
10
  hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
11
 
 
49
  return result['url']
50
  else:
51
  return "์ด๋ฏธ์ง€ ์ƒ์„ฑ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."
52
+
53
+ try:
54
+ result = client.predict(...)
55
+ if 'url' in result:
56
+ return result['url']
57
+ else:
58
+ logging.error("์ด๋ฏธ์ง€ ์ƒ์„ฑ ์‹คํŒจ: %s", result.get('error', '์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜'))
59
+ return "์ด๋ฏธ์ง€ ์ƒ์„ฑ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."
60
  except Exception as e:
61
+ logging.error("API ์š”์ฒญ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: %s", str(e))
62
  return f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
63
+
64
  theme = "Nymbo/Nymbo_Theme"
65
  css = """
66
  footer {