Skip to content

Commit

Permalink
fix: don't pass around the same dict object (nomic-ai#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanussbaum authored Jul 24, 2023
1 parent 41f6405 commit b3f84c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gpt4all-api/gpt4all_api/app/api_v1/routes/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ async def completions(request: CompletionRequest):
params["num_return_sequences"] = request.n

header = {"Content-Type": "application/json"}
payload = {"parameters": params}
if isinstance(request.prompt, list):
tasks = []
for prompt in request.prompt:
payload = {"parameters": params}
payload["inputs"] = prompt
task = gpu_infer(payload, header)
tasks.append(task)

results = await asyncio.gather(*tasks)

choices = []
Expand All @@ -147,6 +146,7 @@ async def completions(request: CompletionRequest):
)

else:
payload = {"parameters": params}
# If streaming, we need to return a StreamingResponse
payload["inputs"] = request.prompt

Expand Down

0 comments on commit b3f84c5

Please sign in to comment.