Skip to content

Commit 4286bc2

Browse files
authored
fix: revert change to ChatAgent and test for example (#664)
1 parent 896c4c4 commit 4286bc2

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

camel/agents/chat_agent.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -522,19 +522,11 @@ def handle_batch_response(
522522
"""
523523
output_messages: List[BaseMessage] = []
524524
for choice in response.choices:
525-
if isinstance(choice.message, list):
526-
# If choice.message is a list, handle accordingly
527-
# It's a check to fit with Nemotron model integration.
528-
content = "".join(
529-
[msg.content for msg in choice.message if msg.content]
530-
)
531-
else:
532-
content = choice.message.content or ""
533525
chat_message = BaseMessage(
534526
role_name=self.role_name,
535527
role_type=self.role_type,
536528
meta_dict=dict(),
537-
content=content,
529+
content=choice.message.content or "",
538530
)
539531
output_messages.append(chat_message)
540532
finish_reasons = [

examples/test/test_role_description_example.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,26 @@
1818
from camel.models import ModelFactory
1919
from camel.types import ModelPlatformType, ModelType
2020

21-
model = ModelFactory.create(
21+
model_gpt = ModelFactory.create(
2222
ModelPlatformType.OPENAI,
2323
model_type=ModelType.GPT_3_5_TURBO,
2424
model_config_dict={},
2525
)
2626

27+
model_stub = ModelFactory.create(
28+
ModelPlatformType.OPENAI,
29+
model_type=ModelType.STUB,
30+
model_config_dict={},
31+
)
32+
2733

2834
def test_role_generation_example():
2935
with patch('time.sleep', return_value=None):
30-
examples.role_description.role_generation.main(model)
36+
examples.role_description.role_generation.main(model_gpt)
3137

3238

3339
def test_role_playing_with_role_description_example():
3440
with patch('time.sleep', return_value=None):
3541
examples.role_description.role_playing_with_role_description.main(
36-
model, model, chat_turn_limit=2
42+
model_gpt, model_stub, chat_turn_limit=2
3743
)

examples/test/test_single_agent.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ def test_single_agent(model):
3939
examples.single_agent.main(model=model)
4040

4141

42-
@parametrize
42+
@pytest.mark.parametrize(
43+
'model',
44+
[
45+
ModelFactory.create(
46+
ModelPlatformType.OPENAI,
47+
model_type=ModelType.STUB,
48+
model_config_dict={},
49+
)
50+
],
51+
)
4352
def test_misalignment_single_agent(model):
4453
examples.misalignment.single_agent.main(model=model)
4554

@@ -54,6 +63,15 @@ def test_code_generate_metadata(model):
5463
examples.code.generate_meta_data.main(model=model)
5564

5665

57-
@parametrize
66+
@pytest.mark.parametrize(
67+
'model',
68+
[
69+
ModelFactory.create(
70+
ModelPlatformType.OPENAI,
71+
model_type=ModelType.STUB,
72+
model_config_dict={},
73+
)
74+
],
75+
)
5876
def test_code_task_generation(model):
5977
examples.code.task_generation.main(model=model)

0 commit comments

Comments
 (0)