File size: 840 Bytes
da0fdaf
de3da4c
 
8b9a116
de3da4c
 
 
 
 
 
 
 
8b9a116
de3da4c
 
 
 
 
 
 
 
 
 
 
8b9a116
 
 
 
 
 
 
9945c15
8b9a116
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import json

def chat_completions(message):
    response = {
        "id": "chatcmpl-123",
        "object": "chat.completion",
        "created": 1677652288,
        "choices": [{
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "This is a placeholder response. The real model isn't loaded yet."
            },
            "finish_reason": "stop"
        }],
        "usage": {
            "prompt_tokens": 9,
            "completion_tokens": 12,
            "total_tokens": 21
        }
    }
    return json.dumps(response)

demo = gr.Interface(
    fn=chat_completions,
    inputs="json",
    outputs="json",
    title="Chat Completions API",
    description="Send a POST request to /v1/chat/completions"
)

if __name__ == "__main__":
    demo.launch()