diff --git a/servers/blip2.py b/servers/blip2.py index b5115b6..2da4061 100644 --- a/servers/blip2.py +++ b/servers/blip2.py @@ -9,7 +9,7 @@ def get_engine_name(rank): - return "rank{}.engine".format(rank) + return f"rank{rank}.engine" def trt_dtype_to_torch(dtype): @@ -20,7 +20,7 @@ def trt_dtype_to_torch(dtype): elif dtype == trt.int32: return torch.int32 else: - raise TypeError("%s is not supported" % dtype) + raise TypeError(f"{dtype} is not supported") def TRTOPT(args, config): diff --git a/servers/cogvlm.py b/servers/cogvlm.py index d296767..40f5a00 100644 --- a/servers/cogvlm.py +++ b/servers/cogvlm.py @@ -220,7 +220,7 @@ async def predict(model_id: str, params: dict): chunk = ChatCompletionResponse( model=model_id, choices=[choice_data], object="chat.completion.chunk" ) - yield "{}".format(chunk.model_dump_json(exclude_unset=True)) + yield f"{chunk.model_dump_json(exclude_unset=True)}" previous_text = "" for new_response in generate_stream_cogvlm(model, tokenizer, params): @@ -238,7 +238,7 @@ async def predict(model_id: str, params: dict): chunk = ChatCompletionResponse( model=model_id, choices=[choice_data], object="chat.completion.chunk" ) - yield "{}".format(chunk.model_dump_json(exclude_unset=True)) + yield f"{chunk.model_dump_json(exclude_unset=True)}" choice_data = ChatCompletionResponseStreamChoice( index=0, delta=DeltaMessage(), @@ -246,7 +246,7 @@ async def predict(model_id: str, params: dict): chunk = ChatCompletionResponse( model=model_id, choices=[choice_data], object="chat.completion.chunk" ) - yield "{}".format(chunk.model_dump_json(exclude_unset=True)) + yield f"{chunk.model_dump_json(exclude_unset=True)}" def generate_cogvlm( @@ -405,9 +405,7 @@ def generate_stream_cogvlm( torch_type = torch.float16 print( - "========Use torch type as:{} with device:{}========\n\n".format( - torch_type, DEVICE - ) + f"========Use torch type as:{torch_type} with device:{DEVICE}========\n\n" ) if "cuda" in DEVICE: diff --git a/servers/qwen_tensort.py b/servers/qwen_tensort.py index 3325b79..a02a0b2 100644 --- a/servers/qwen_tensort.py +++ b/servers/qwen_tensort.py @@ -30,8 +30,8 @@ def get_engine_name(model, dtype, tp_size, pp_size, rank): if pp_size == 1: - return "{}_{}_tp{}_rank{}.engine".format(model, dtype, tp_size, rank) - return "{}_{}_tp{}_pp{}_rank{}.engine".format(model, dtype, tp_size, pp_size, rank) + return f"{model}_{dtype}_tp{tp_size}_rank{rank}.engine" + return f"{model}_{dtype}_tp{tp_size}_pp{pp_size}_rank{rank}.engine" def trt_dtype_to_torch(dtype): @@ -42,7 +42,7 @@ def trt_dtype_to_torch(dtype): elif dtype == trt.int32: return torch.int32 else: - raise TypeError("%s is not supported" % dtype) + raise TypeError(f"{dtype} is not supported") class QWenInfer(object): diff --git a/swarms_cloud/sky_api.py b/swarms_cloud/sky_api.py index 58e8c75..00c2239 100644 --- a/swarms_cloud/sky_api.py +++ b/swarms_cloud/sky_api.py @@ -95,7 +95,7 @@ def execute(self, task: Task = None, cluster_name: str = None, **kwargs): _type_: _description_ """ if cluster_name not in self.clusters: - raise ValueError("Cluster {} does not exist".format(cluster_name)) + raise ValueError(f"Cluster {cluster_name} does not exist") try: return sky.exec( task=task,