Skip to content

Commit

Permalink
Merge pull request #588 from exo-explore/betterdl
Browse files Browse the repository at this point in the history
better download
  • Loading branch information
AlexCheema authored Jan 5, 2025
2 parents 7b16561 + 29244c6 commit d9a836f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions exo/api/chatgpt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ async def handle_model_support(self, request):
)
await response.prepare(request)

for model_name, pretty in pretty_name.items():
async def process_model(model_name, pretty):
if model_name in model_cards:
model_info = model_cards[model_name]

Expand Down Expand Up @@ -273,6 +273,12 @@ async def handle_model_support(self, request):

await response.write(f"data: {json.dumps(model_data)}\n\n".encode())

# Process all models in parallel
await asyncio.gather(*[
process_model(model_name, pretty)
for model_name, pretty in pretty_name.items()
])

await response.write(b"data: [DONE]\n\n")
return response

Expand Down Expand Up @@ -562,7 +568,7 @@ async def handle_post_download(self, request):
if model_name not in model_cards: return web.json_response({"error": f"Invalid model: {model_name}. Supported models: {list(model_cards.keys())}"}, status=400)
shard = build_base_shard(model_name, self.inference_engine_classname)
if not shard: return web.json_response({"error": f"Could not build shard for model {model_name}"}, status=400)
asyncio.create_task(self.node.inference_engine.ensure_shard(shard))
asyncio.create_task(self.node.inference_engine.shard_downloader.ensure_shard(shard, self.inference_engine_classname))

return web.json_response({
"status": "success",
Expand Down

0 comments on commit d9a836f

Please sign in to comment.