add option for request
Browse files- api_server.py +13 -0
api_server.py
CHANGED
|
@@ -1030,6 +1030,19 @@ async def list_models():
|
|
| 1030 |
})
|
| 1031 |
return {"object": "list", "data": data}
|
| 1032 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
@app.post("/v1/chat/completions")
|
| 1034 |
async def chat_completions(req: ChatCompletionRequest, request: Request):
|
| 1035 |
chat_id = f"chatcmpl-{uuid.uuid4().hex[:12]}"
|
|
|
|
| 1030 |
})
|
| 1031 |
return {"object": "list", "data": data}
|
| 1032 |
|
| 1033 |
+
@app.options("/v1/chat/completions")
|
| 1034 |
+
async def options_chat_completions():
|
| 1035 |
+
return Response(
|
| 1036 |
+
status_code=200,
|
| 1037 |
+
headers={
|
| 1038 |
+
"Allow": "POST, OPTIONS",
|
| 1039 |
+
"Access-Control-Allow-Origin": "*",
|
| 1040 |
+
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
| 1041 |
+
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
| 1042 |
+
},
|
| 1043 |
+
)
|
| 1044 |
+
|
| 1045 |
+
|
| 1046 |
@app.post("/v1/chat/completions")
|
| 1047 |
async def chat_completions(req: ChatCompletionRequest, request: Request):
|
| 1048 |
chat_id = f"chatcmpl-{uuid.uuid4().hex[:12]}"
|