Skip to content

Commit d476125

Browse files
committed
comment
Change-Id: If1499dadbbc1dfbe54bc6218209b4e0cc8a44b5c
1 parent a1980eb commit d476125

4 files changed

Lines changed: 41 additions & 41 deletions

File tree

cozeloop/_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ def execute_prompt(
282282
timeout: Optional[int] = None
283283
) -> Union[ExecuteResult, StreamReader[ExecuteResult]]:
284284
"""
285-
执行Prompt请求
285+
Execute Prompt request
286286
287-
:param timeout: 请求超时时间(秒),可选,默认为600秒(10分钟)
287+
:param timeout: Request timeout (seconds), optional, default is 600 seconds (10 minutes)
288288
"""
289289
if self._closed:
290290
raise ClientClosedError()
@@ -310,9 +310,9 @@ async def aexecute_prompt(
310310
timeout: Optional[int] = None
311311
) -> Union[ExecuteResult, StreamReader[ExecuteResult]]:
312312
"""
313-
异步执行Prompt请求
313+
Asynchronously execute Prompt request
314314
315-
:param timeout: 请求超时时间(秒),可选,默认为600秒(10分钟)
315+
:param timeout: Request timeout (seconds), optional, default is 600 seconds (10 minutes)
316316
"""
317317
if self._closed:
318318
raise ClientClosedError()
@@ -436,9 +436,9 @@ def execute_prompt(
436436
timeout: Optional[int] = None
437437
) -> Union[ExecuteResult, StreamReader[ExecuteResult]]:
438438
"""
439-
执行Prompt请求
439+
Execute Prompt request
440440
441-
:param timeout: 请求超时时间(秒),可选,默认为600秒(10分钟)
441+
:param timeout: Request timeout (seconds), optional, default is 600 seconds (10 minutes)
442442
"""
443443
return get_default_client().execute_prompt(
444444
prompt_key,
@@ -462,9 +462,9 @@ async def aexecute_prompt(
462462
timeout: Optional[int] = None
463463
) -> Union[ExecuteResult, StreamReader[ExecuteResult]]:
464464
"""
465-
异步执行Prompt请求
465+
Asynchronously execute Prompt request
466466
467-
:param timeout: 请求超时时间(秒),可选,默认为600秒(10分钟)
467+
:param timeout: Request timeout (seconds), optional, default is 600 seconds (10 minutes)
468468
"""
469469
return await get_default_client().aexecute_prompt(
470470
prompt_key,

cozeloop/internal/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
22
# SPDX-License-Identifier: MIT
33

4-
VERSION = 'v0.1.10'
4+
VERSION = 'v0.1.11'

examples/prompt/prompt_hub/prompt_hub_with_label.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def convert_model_input(messages: List[Message]) -> ModelInput:
16-
""" cozeloop Message 转换为 ModelInput"""
16+
"""Convert cozeloop Message to ModelInput"""
1717
model_messages = []
1818
for message in messages:
1919
model_messages.append(ModelMessage(
@@ -27,27 +27,27 @@ def convert_model_input(messages: List[Message]) -> ModelInput:
2727

2828

2929
class LLMRunner:
30-
"""LLM 运行器,用于模拟 LLM 调用并设置相关的 span 标签"""
30+
"""LLM runner for simulating LLM calls and setting related span tags"""
3131

3232
def __init__(self, client):
3333
self.client = client
3434

3535
def llm_call(self, input_data):
3636
"""
37-
模拟 LLM 调用并设置相关的 span 标签
37+
Simulate LLM call and set related span tags
3838
"""
3939
span = self.client.start_span("llmCall", "model")
4040
try:
41-
# 模拟 LLM 处理过程
41+
# Simulate LLM processing
4242
# output = ChatOpenAI().invoke(input=input_data)
4343

44-
# 模拟响应
44+
# Simulate response
4545
time.sleep(1)
4646
output = "I'm a robot. I don't have a specific name. You can give me one."
4747
input_token = 232
4848
output_token = 1211
4949

50-
# 设置 span 标签
50+
# Set span tags
5151
span.set_input(convert_model_input(input_data))
5252
span.set_output(output)
5353
span.set_model_provider("openai")
@@ -137,4 +137,4 @@ def llm_call(self, input_data):
137137
# Warning! In general, this method is not needed to be call, as spans will be automatically reported in batches.
138138
# Note that flush will block and wait for the report to complete, and it may cause frequent reporting,
139139
# affecting performance.
140-
client.flush()
140+
client.flush()

tests/internal/prompt/test_prompt.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -636,18 +636,18 @@ def test_format_normal_messages_null_message(prompt_provider):
636636
assert result[1].role == Role.USER
637637
assert result[1].content == "World"
638638
def test_validate_variable_values_type_boolean_valid(prompt_provider):
639-
"""测试有效的 boolean 类型变量"""
639+
"""Test valid boolean type variable"""
640640
var_defs = [VariableDef(key="enabled", desc="Enable feature", type=VariableType.BOOLEAN)]
641641
variables = {"enabled": True}
642642

643-
# 应该不抛出异常
643+
# Should not raise exception
644644
prompt_provider._validate_variable_values_type(var_defs, variables)
645645

646646

647647
def test_validate_variable_values_type_boolean_invalid(prompt_provider):
648-
"""测试无效的 boolean 类型变量"""
648+
"""Test invalid boolean type variable"""
649649
var_defs = [VariableDef(key="enabled", desc="Enable feature", type=VariableType.BOOLEAN)]
650-
variables = {"enabled": "true"} # 字符串而不是布尔值
650+
variables = {"enabled": "true"} # String instead of boolean
651651

652652
with pytest.raises(ValueError) as excinfo:
653653
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -656,18 +656,18 @@ def test_validate_variable_values_type_boolean_invalid(prompt_provider):
656656

657657

658658
def test_validate_variable_values_type_integer_valid(prompt_provider):
659-
"""测试有效的 integer 类型变量"""
659+
"""Test valid integer type variable"""
660660
var_defs = [VariableDef(key="count", desc="Item count", type=VariableType.INTEGER)]
661661
variables = {"count": 42}
662662

663-
# 应该不抛出异常
663+
# Should not raise exception
664664
prompt_provider._validate_variable_values_type(var_defs, variables)
665665

666666

667667
def test_validate_variable_values_type_integer_invalid(prompt_provider):
668-
"""测试无效的 integer 类型变量"""
668+
"""Test invalid integer type variable"""
669669
var_defs = [VariableDef(key="count", desc="Item count", type=VariableType.INTEGER)]
670-
variables = {"count": "42"} # 字符串而不是整数
670+
variables = {"count": "42"} # String instead of integer
671671

672672
with pytest.raises(ValueError) as excinfo:
673673
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -676,18 +676,18 @@ def test_validate_variable_values_type_integer_invalid(prompt_provider):
676676

677677

678678
def test_validate_variable_values_type_float_valid(prompt_provider):
679-
"""测试有效的 float 类型变量"""
679+
"""Test valid float type variable"""
680680
var_defs = [VariableDef(key="temperature", desc="Temperature value", type=VariableType.FLOAT)]
681681
variables = {"temperature": 3.14}
682682

683-
# 应该不抛出异常
683+
# Should not raise exception
684684
prompt_provider._validate_variable_values_type(var_defs, variables)
685685

686686

687687
def test_validate_variable_values_type_float_invalid(prompt_provider):
688-
"""测试无效的 float 类型变量"""
688+
"""Test invalid float type variable"""
689689
var_defs = [VariableDef(key="temperature", desc="Temperature value", type=VariableType.FLOAT)]
690-
variables = {"temperature": "3.14"} # 字符串而不是浮点数
690+
variables = {"temperature": "3.14"} # String instead of float
691691

692692
with pytest.raises(ValueError) as excinfo:
693693
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -696,18 +696,18 @@ def test_validate_variable_values_type_float_invalid(prompt_provider):
696696

697697

698698
def test_validate_variable_values_type_array_string_valid(prompt_provider):
699-
"""测试有效的 array<string> 类型变量"""
699+
"""Test valid array<string> type variable"""
700700
var_defs = [VariableDef(key="tags", desc="Tag list", type=VariableType.ARRAY_STRING)]
701701
variables = {"tags": ["tag1", "tag2", "tag3"]}
702702

703-
# 应该不抛出异常
703+
# Should not raise exception
704704
prompt_provider._validate_variable_values_type(var_defs, variables)
705705

706706

707707
def test_validate_variable_values_type_array_string_invalid_not_list(prompt_provider):
708-
"""测试无效的 array<string> 类型变量 - 不是列表"""
708+
"""Test invalid array<string> type variable - not a list"""
709709
var_defs = [VariableDef(key="tags", desc="Tag list", type=VariableType.ARRAY_STRING)]
710-
variables = {"tags": "tag1,tag2,tag3"} # 字符串而不是列表
710+
variables = {"tags": "tag1,tag2,tag3"} # String instead of list
711711

712712
with pytest.raises(ValueError) as excinfo:
713713
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -716,9 +716,9 @@ def test_validate_variable_values_type_array_string_invalid_not_list(prompt_prov
716716

717717

718718
def test_validate_variable_values_type_array_string_invalid_wrong_element_type(prompt_provider):
719-
"""测试无效的 array<string> 类型变量 - 元素类型错误"""
719+
"""Test invalid array<string> type variable - wrong element type"""
720720
var_defs = [VariableDef(key="tags", desc="Tag list", type=VariableType.ARRAY_STRING)]
721-
variables = {"tags": ["tag1", 123, "tag3"]} # 包含非字符串元素
721+
variables = {"tags": ["tag1", 123, "tag3"]} # Contains non-string elements
722722

723723
with pytest.raises(ValueError) as excinfo:
724724
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -727,18 +727,18 @@ def test_validate_variable_values_type_array_string_invalid_wrong_element_type(p
727727

728728

729729
def test_validate_variable_values_type_array_boolean_valid(prompt_provider):
730-
"""测试有效的 array<boolean> 类型变量"""
730+
"""Test valid array<boolean> type variable"""
731731
var_defs = [VariableDef(key="flags", desc="Boolean flags", type=VariableType.ARRAY_BOOLEAN)]
732732
variables = {"flags": [True, False, True]}
733733

734-
# 应该不抛出异常
734+
# Should not raise exception
735735
prompt_provider._validate_variable_values_type(var_defs, variables)
736736

737737

738738
def test_validate_variable_values_type_array_boolean_invalid(prompt_provider):
739-
"""测试无效的 array<boolean> 类型变量"""
739+
"""Test invalid array<boolean> type variable"""
740740
var_defs = [VariableDef(key="flags", desc="Boolean flags", type=VariableType.ARRAY_BOOLEAN)]
741-
variables = {"flags": [True, "false", True]} # 包含字符串而不是布尔值
741+
variables = {"flags": [True, "false", True]} # Contains string instead of boolean
742742

743743
with pytest.raises(ValueError) as excinfo:
744744
prompt_provider._validate_variable_values_type(var_defs, variables)
@@ -747,16 +747,16 @@ def test_validate_variable_values_type_array_boolean_invalid(prompt_provider):
747747

748748

749749
def test_validate_variable_values_type_array_integer_valid(prompt_provider):
750-
"""测试有效的 array<integer> 类型变量"""
750+
"""Test valid array<integer> type variable"""
751751
var_defs = [VariableDef(key="numbers", desc="Number list", type=VariableType.ARRAY_INTEGER)]
752752
variables = {"numbers": [1, 2, 3, 4, 5]}
753753

754-
# 应该不抛出异常
754+
# Should not raise exception
755755
prompt_provider._validate_variable_values_type(var_defs, variables)
756756

757757

758758
def test_validate_variable_values_type_array_integer_invalid(prompt_provider):
759-
"""测试无效的 array<integer> 类型变量"""
759+
"""Test invalid array<integer> type variable"""
760760
var_defs = [VariableDef(key="numbers", desc="Number list", type=VariableType.ARRAY_INTEGER)]
761761
variables = {"numbers": [1, "2", 3]} # 包含字符串而不是整数
762762

0 commit comments

Comments
 (0)