plannist
commited on
Commit
·
f9c8470
1
Parent(s):
a378469
app.py
CHANGED
@@ -27,15 +27,28 @@ def chat_fn(prompt):
|
|
27 |
return output
|
28 |
except Exception as e:
|
29 |
return [f"Error: {str(e)}"]
|
|
|
|
|
30 |
with gr.Blocks() as demo:
|
31 |
-
gr.
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
demo.
|
40 |
-
|
41 |
-
demo.launch(share=False)
|
|
|
27 |
return output
|
28 |
except Exception as e:
|
29 |
return [f"Error: {str(e)}"]
|
30 |
+
|
31 |
+
|
32 |
with gr.Blocks() as demo:
|
33 |
+
with gr.Row():
|
34 |
+
input_box = gr.Textbox(label="Prompt", lines=2)
|
35 |
+
with gr.Row():
|
36 |
+
output_box = gr.Textbox(label="Response")
|
37 |
+
|
38 |
+
btn = gr.Button("Generate")
|
39 |
+
btn.click(chat_fn, inputs=input_box, outputs=output_box)
|
40 |
+
|
41 |
+
# ✅ Hugging Face Spaces의 API 요청용 endpoint 정의
|
42 |
+
gr.Examples(
|
43 |
+
examples=["안녕?", "한국에 대해 말해줘"],
|
44 |
+
inputs=input_box
|
45 |
+
)
|
46 |
+
|
47 |
+
demo.load(chat_fn, inputs=input_box, outputs=output_box)
|
48 |
|
49 |
+
# ✅ API endpoint로 사용할 Interface 객체 등록
|
50 |
+
api_demo = gr.Interface(fn=chat_fn, inputs="text", outputs="text", name="predict")
|
51 |
|
52 |
+
if __name__ == "__main__":
|
53 |
+
demo.queue()
|
54 |
+
api_demo.launch(share=False)
|
|