leafspark commited on
Commit
40e9cae
1 Parent(s): 9945c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -2,10 +2,7 @@ import gradio as gr
2
  import json
3
 
4
  def chat_completions(request: gr.Request):
5
- # Parse the incoming JSON request
6
  data = request.json
7
-
8
- # Create a placeholder response
9
  response = {
10
  "id": "chatcmpl-123",
11
  "object": "chat.completion",
@@ -26,17 +23,11 @@ def chat_completions(request: gr.Request):
26
  }
27
  return json.dumps(response)
28
 
29
- demo = gr.Interface(
30
- fn=chat_completions,
31
- inputs=None,
32
- outputs=None,
33
- title="Chat Completions API",
34
- description="Send a POST request to /v1/chat/completions"
35
- )
36
-
37
- if __name__ == "__main__":
38
- demo.launch()
39
 
40
  demo.queue()
41
  demo.launch()
42
- api = gr.mount_gradio_app(demo, "/v1/chat/completions", api_name="chat_completions")
 
 
2
  import json
3
 
4
  def chat_completions(request: gr.Request):
 
5
  data = request.json
 
 
6
  response = {
7
  "id": "chatcmpl-123",
8
  "object": "chat.completion",
 
23
  }
24
  return json.dumps(response)
25
 
26
+ with gr.Blocks() as demo:
27
+ gr.Markdown("# Chat Completions API")
28
+ gr.Markdown("Send a POST request to /v1/chat/completions")
 
 
 
 
 
 
 
29
 
30
  demo.queue()
31
  demo.launch()
32
+
33
+ app = gr.mount_gradio_app(demo, "/v1/chat/completions", chat_completions)