From 7c06141ce2e0e6238a89cd3113b203049611b586 Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Wed, 10 Jul 2024 00:07:32 +0800 Subject: [PATCH] =?UTF-8?q?perf(ollama):=20=E4=BC=98=E5=8C=96=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E6=98=BE=E7=A4=BA=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/command/operators/ollama.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/command/operators/ollama.py b/pkg/command/operators/ollama.py index 05c12d02..db47918e 100644 --- a/pkg/command/operators/ollama.py +++ b/pkg/command/operators/ollama.py @@ -21,8 +21,8 @@ class OllamaOperator(operator.CommandOperator): for model in model_list: content += f"name: {model['name']}\n" content += f"modified_at: {model['modified_at']}\n" - content += f"size: {bytes_to_mb(model['size'])}mb\n\n" - yield entities.CommandReturn(text=f"{content}") + content += f"size: {bytes_to_mb(model['size'])}MB\n\n" + yield entities.CommandReturn(text=f"{content.strip()}") def bytes_to_mb(num_bytes): @@ -56,7 +56,7 @@ class OllamaShowOperator(operator.CommandOperator): except ollama.ResponseError as e: content = f"{e.error}" - yield entities.CommandReturn(text=content) + yield entities.CommandReturn(text=content.strip()) @operator.operator_class( @@ -93,7 +93,7 @@ class OllamaPullOperator(operator.CommandOperator): if percentage_completed > progress_count: progress_count += 10 yield entities.CommandReturn( - text=f"下载进度: {completed}/{total} = {percentage_completed:.2f}%") + text=f"下载进度: {completed}/{total} ({percentage_completed:.2f}%)") except ollama.ResponseError as e: yield entities.CommandReturn(text=f"拉取失败: {e.error}")