Spaces:
Sleeping
Sleeping
# gradio λΌμ΄λΈλ¬λ¦¬λ₯Ό gr λ³μΉμΌλ‘ μν¬νΈν©λλ€. | |
import gradio as gr | |
from gradio_client import Client | |
import httpx | |
# Client κ°μ²΄ μμ± μ timeout 맀κ°λ³μ μ κ±° | |
client = Client("seawolf2357/sajuice") | |
# νμμμ κ°μ μ΄ λ¨μλ‘ μ€μ ν©λλ€. μ: μ½κΈ° νμμμμ 30μ΄λ‘ μ€μ | |
timeout_config = httpx.Timeout(5.0, read=30.0) | |
try: | |
# μμ λ νμμμ μ€μ μ μ μ©νμ¬ ν΄λΌμ΄μΈνΈλ₯Ό μμ±ν©λλ€. | |
client = Client("arxivgpt/sajutest", timeout=timeout_config) | |
print("ν΄λΌμ΄μΈνΈκ° μ±κ³΅μ μΌλ‘ μμ±λμμ΅λλ€.") | |
except httpx.ReadTimeout: | |
print("μμ² μκ° μ΄κ³Ό: μλ²κ° μ§μ λ μκ° λ΄μ μλ΅νμ§ μμμ΅λλ€.") | |
except Exception as e: | |
print(f"μμμΉ λͺ»ν μ€λ₯κ° λ°μνμ΅λλ€: {e}") | |
def call_api(μλ , μμ, μμΌ, μμ): | |
# APIλ₯Ό νΈμΆνκ³ μλ΅κ°μ λ°μ΅λλ€. | |
result = client.predict( | |
μλ , # 'μλ (μ: 1990)'μ λν μ λ ₯κ° | |
μμ, # 'μμ(μ: 01)'μ λν μ λ ₯κ° | |
μμΌ, # 'μμΌ(μ: 31)'μ λν μ λ ₯κ° | |
μμ, # 'μμ(μμ: 1030)'μ λν μ λ ₯κ° | |
api_name="/get_lunar_info" | |
) | |
return result | |
# Gradio μΈν°νμ΄μ€λ₯Ό μ μν©λλ€. | |
inputs = [ | |
gr.Textbox(label="μλ (μ: 1990)"), | |
gr.Textbox(label="μμ(μ: 01)"), | |
gr.Textbox(label="μμΌ(μ: 31)"), | |
gr.Textbox(label="μμ(μμ: 1030)") | |
] | |
outputs = gr.Textbox(label="κ²°κ³Ό") | |
# μΈν°νμ΄μ€λ₯Ό μμ±νκ³ μ€νν©λλ€. | |
gr.Interface(fn=call_api, inputs=inputs, outputs=outputs, title="Get Lunar Info").launch() | |