plannist commited on
Commit
a378469
·
1 Parent(s): fb501b9
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -24,9 +24,18 @@ pipe = pipeline(
24
  def chat_fn(prompt):
25
  try:
26
  output = pipe(prompt)[0]["generated_text"]
27
- return [output]
28
  except Exception as e:
29
  return [f"Error: {str(e)}"]
 
 
 
 
 
30
 
31
- demo = gr.Interface(fn=chat_fn, inputs="text", outputs="text")
 
 
 
 
32
  demo.launch(share=False)
 
24
  def chat_fn(prompt):
25
  try:
26
  output = pipe(prompt)[0]["generated_text"]
27
+ return output
28
  except Exception as e:
29
  return [f"Error: {str(e)}"]
30
+ with gr.Blocks() as demo:
31
+ gr.Markdown("### 🐯 KoAlpaca Chatbot")
32
+ inp = gr.Textbox(label="Input")
33
+ out = gr.Textbox(label="Output")
34
+ btn = gr.Button("Submit")
35
 
36
+ btn.click(fn=chat_fn, inputs=inp, outputs=out)
37
+
38
+ # API endpoint 등록
39
+ demo.api(chat_fn, inputs=gr.Textbox(label="prompt"), outputs=gr.Textbox(), name="predict")
40
+
41
  demo.launch(share=False)