Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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 |
-
|
|
|
|
|
|
| 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)
|