Skip to content

Commit 14f207b

Browse files
authored
LiteLLM now supports Cohere (#336)
1 parent 8cff360 commit 14f207b

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/server/api/utils/oci.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ def get_genai_models(config: OracleCloudSettings, regional: bool = False) -> lis
247247
try:
248248
response = client.list_models(
249249
compartment_id=config.genai_compartment_id,
250-
capability=["TEXT_EMBEDDINGS", "CHAT"],
251250
lifecycle_state="ACTIVE",
252251
sort_order="ASC",
253252
sort_by="displayName",
@@ -263,12 +262,8 @@ def get_genai_models(config: OracleCloudSettings, regional: bool = False) -> lis
263262
# Build list of models (excluding deprecated ones and duplicates)
264263
for model in response.data.items:
265264
model_key = (region["region_name"], model.display_name)
266-
# Skip if deprecated, duplicate, or cohere model without TEXT_EMBEDDINGS
267-
if (
268-
model.display_name in excluded_display_names
269-
or model_key in seen_models
270-
or (model.vendor == "cohere" and "TEXT_EMBEDDINGS" not in model.capabilities)
271-
):
265+
# Skip if deprecated and duplicated
266+
if model.display_name in excluded_display_names or model_key in seen_models:
272267
continue
273268

274269
seen_models.add(model_key)
@@ -375,14 +370,12 @@ def get_bucket_objects_with_metadata(bucket_name: str, config: OracleCloudSettin
375370
objects_metadata = []
376371
try:
377372
response = client.list_objects(
378-
namespace_name=config.namespace,
379-
bucket_name=bucket_name,
380-
fields="name,size,etag,timeModified,md5"
373+
namespace_name=config.namespace, bucket_name=bucket_name, fields="name,size,etag,timeModified,md5"
381374
)
382375
objects = response.data.objects
383376

384377
# Filter supported file types and add metadata
385-
supported_extensions = {'.pdf', '.html', '.md', '.txt', '.csv', '.png', '.jpg', '.jpeg'}
378+
supported_extensions = {".pdf", ".html", ".md", ".txt", ".csv", ".png", ".jpg", ".jpeg"}
386379

387380
for obj in objects:
388381
_, ext = os.path.splitext(obj.name.lower())
@@ -393,7 +386,7 @@ def get_bucket_objects_with_metadata(bucket_name: str, config: OracleCloudSettin
393386
"etag": obj.etag,
394387
"time_modified": obj.time_modified.isoformat() if obj.time_modified else None,
395388
"md5": obj.md5,
396-
"extension": ext[1:] # Remove the dot
389+
"extension": ext[1:], # Remove the dot
397390
}
398391
objects_metadata.append(obj_metadata)
399392
except oci.exceptions.ServiceError:
@@ -403,10 +396,7 @@ def get_bucket_objects_with_metadata(bucket_name: str, config: OracleCloudSettin
403396
return objects_metadata
404397

405398

406-
def detect_changed_objects(
407-
current_objects: list[dict],
408-
processed_objects: dict
409-
) -> tuple[list[dict], list[dict]]:
399+
def detect_changed_objects(current_objects: list[dict], processed_objects: dict) -> tuple[list[dict], list[dict]]:
410400
"""
411401
Detect new and modified objects by comparing current bucket state
412402
with previously processed objects metadata
@@ -437,8 +427,9 @@ def detect_changed_objects(
437427
continue
438428

439429
# Compare etag and modification time
440-
if (obj["etag"] != last_processed.get("etag") or
441-
obj["time_modified"] != last_processed.get("time_modified")):
430+
if obj["etag"] != last_processed.get("etag") or obj["time_modified"] != last_processed.get(
431+
"time_modified"
432+
):
442433
modified_objects.append(obj)
443434

444435
logger.info("Found %d new objects and %d modified objects", len(new_objects), len(modified_objects))

0 commit comments

Comments
 (0)