Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 {
|