Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
|
4 |
-
def chat_completions(
|
5 |
-
data = request.json
|
6 |
response = {
|
7 |
"id": "chatcmpl-123",
|
8 |
"object": "chat.completion",
|
@@ -11,7 +10,7 @@ def chat_completions(request: gr.Request):
|
|
11 |
"index": 0,
|
12 |
"message": {
|
13 |
"role": "assistant",
|
14 |
-
"content":
|
15 |
},
|
16 |
"finish_reason": "stop"
|
17 |
}],
|
@@ -23,11 +22,13 @@ def chat_completions(request: gr.Request):
|
|
23 |
}
|
24 |
return json.dumps(response)
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
demo.launch()
|
32 |
-
|
33 |
-
app = gr.mount_gradio_app(demo, "/v1/chat/completions", chat_completions)
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
|
4 |
+
def chat_completions(message):
|
|
|
5 |
response = {
|
6 |
"id": "chatcmpl-123",
|
7 |
"object": "chat.completion",
|
|
|
10 |
"index": 0,
|
11 |
"message": {
|
12 |
"role": "assistant",
|
13 |
+
"content": "This is a placeholder response. The real model isn't loaded yet."
|
14 |
},
|
15 |
"finish_reason": "stop"
|
16 |
}],
|
|
|
22 |
}
|
23 |
return json.dumps(response)
|
24 |
|
25 |
+
demo = gr.Interface(
|
26 |
+
fn=chat_completions,
|
27 |
+
inputs="json",
|
28 |
+
outputs="json",
|
29 |
+
title="Chat Completions API",
|
30 |
+
description="Send a POST request to /v1/chat/completions"
|
31 |
+
)
|
32 |
|
33 |
+
if __name__ == "__main__":
|
34 |
+
demo.launch()
|
|
|
|