(fix) locust load test

This commit is contained in:
ishaan-jaff 2024-03-12 18:52:49 -07:00
parent 8bfb00cdab
commit 786df1d574
2 changed files with 3 additions and 1 deletions

View file

@ -8,6 +8,7 @@ class MyUser(HttpUser):
def chat_completion(self): def chat_completion(self):
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer sk-1234",
# Include any additional headers you may need for authentication, etc. # Include any additional headers you may need for authentication, etc.
} }

View file

@ -6,6 +6,7 @@ from fastapi import FastAPI, Request, status, HTTPException, Depends
from fastapi.responses import StreamingResponse from fastapi.responses import StreamingResponse
from fastapi.security import OAuth2PasswordBearer from fastapi.security import OAuth2PasswordBearer
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
import uuid
app = FastAPI() app = FastAPI()
@ -23,7 +24,7 @@ app.add_middleware(
@app.post("/v1/chat/completions") @app.post("/v1/chat/completions")
async def completion(request: Request): async def completion(request: Request):
return { return {
"id": "chatcmpl-123", "id": f"chatcmpl-{uuid.uuid4().hex}",
"object": "chat.completion", "object": "chat.completion",
"created": 1677652288, "created": 1677652288,
"model": "gpt-3.5-turbo-0125", "model": "gpt-3.5-turbo-0125",