Spaces:
Sleeping
Sleeping
| 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() |