Nexchan commited on
Commit
1e4892f
·
verified ·
1 Parent(s): 6b0e09f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -68,9 +68,20 @@ with gr.Blocks() as demo:
68
  msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
69
  send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
70
 
71
- # Menambahkan endpoint API
72
- demo.load(fn=api_chat, inputs="state", outputs="state")
 
 
73
 
 
 
 
 
 
 
 
 
74
 
75
  if __name__ == "__main__":
76
- demo.launch()
 
 
68
  msg.submit(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
69
  send_btn.click(fn=chat_mem, inputs=[msg, chatbot], outputs=[msg, chatbot])
70
 
71
+ # Mengatur endpoint API
72
+ def api_endpoint(chat_history: List[Dict[str, str]]):
73
+ updated_history = api_chat(chat_history)
74
+ return updated_history
75
 
76
+ # Membuat interface API
77
+ api_interface = gr.Interface(
78
+ fn=api_endpoint,
79
+ inputs=gr.inputs.JSON(),
80
+ outputs=gr.outputs.JSON(),
81
+ title="Chat API",
82
+ description="Endpoint API untuk berinteraksi dengan model chat."
83
+ )
84
 
85
  if __name__ == "__main__":
86
+ demo.launch()
87
+ api_interface.launch(server_name="0.0.0.0", server_port=7860)