refac: ollama connections

This commit is contained in:
Timothy Jaeryang Baek 2024-11-11 22:46:47 -08:00
parent 99446c4b76
commit 08b5e7ef5b

View File

@ -263,12 +263,12 @@ def merge_models_lists(model_lists):
for idx, model_list in enumerate(model_lists):
if model_list is not None:
for model in model_list:
digest = model["digest"]
if digest not in merged_models:
id = model["model"]
if id not in merged_models:
model["urls"] = [idx]
merged_models[digest] = model
merged_models[id] = model
else:
merged_models[digest]["urls"].append(idx)
merged_models[id]["urls"].append(idx)
return list(merged_models.values())
@ -312,6 +312,8 @@ async def get_all_models():
for model in response["models"]:
model["model"] = f"{prefix_id}.{model['model']}"
print(responses)
models = {
"models": merge_models_lists(
map(