Skip to content

Commit 640b82d

Browse files
author
root
committed
掺入20%其他大模型agent
1 parent efb5253 commit 640b82d

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

examples/werewolf/train.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ python -m agentlightning.verl \
5151
trainer.project_name=${PROJECT_NAME} \
5252
trainer.experiment_name=${EXPERIMENT_NAME} \
5353
trainer.nnodes=1 \
54-
trainer.save_freq=1 \
54+
trainer.save_freq=10 \
5555
trainer.test_freq=0 \
5656
trainer.total_epochs=1 $@

examples/werewolf/werewolf_agent.py

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -306,32 +306,49 @@ async def create_player(role: str, NAME_TO_ROLE: dict, ch_names: dict, moderato
306306
"""Create a player with the given name and role."""
307307
name = get_player_name(candidate_names)
308308
NAME_TO_ROLE[name] = role
309-
agent = ReActAgent(
310-
name=name,
311-
sys_prompt=Prompts.system_prompt.format(
312-
player_name=name,
313-
guidance=getattr(Prompts, f"notes_{role}"),
314-
),
315-
# model=DashScopeChatModel(
316-
# model_name="qwen3-max-preview",
317-
# api_key=os.environ["DASHSCOPE_API_KEY"],
318-
# enable_thinking=True,
319-
# ),
320-
# model=OpenAIChatModel(
321-
# model_name="/root/dataDisk/Qwen3-8B",
322-
# client_args={"base_url": "http://127.0.0.1:8000/v1"},
323-
# api_key="xxx",
324-
# stream=False,
325-
# ),
326-
model=OpenAIChatModel(
327-
model_name=llm.model,
328-
client_args={"base_url": llm.endpoint},
329-
api_key="xxx",
330-
stream=False,
331-
),
332-
# formatter=DashScopeMultiAgentFormatter(),
333-
formatter=OpenAIMultiAgentFormatter(),
334-
)
309+
#添加外部对抗性
310+
import random
311+
if random.random() < 0.8:
312+
agent = ReActAgent(
313+
name=name,
314+
sys_prompt=Prompts.system_prompt.format(
315+
player_name=name,
316+
guidance=getattr(Prompts, f"notes_{role}"),
317+
),
318+
# model=DashScopeChatModel(
319+
# model_name="qwen3-max-preview",
320+
# api_key=os.environ["DASHSCOPE_API_KEY"],
321+
# enable_thinking=True,
322+
# ),
323+
# model=OpenAIChatModel(
324+
# model_name="/root/dataDisk/Qwen3-8B",
325+
# client_args={"base_url": "http://127.0.0.1:8000/v1"},
326+
# api_key="xxx",
327+
# stream=False,
328+
# ),
329+
model=OpenAIChatModel(
330+
model_name=llm.model,
331+
client_args={"base_url": llm.endpoint},
332+
api_key="xxx",
333+
stream=False,
334+
),
335+
# formatter=DashScopeMultiAgentFormatter(),
336+
formatter=OpenAIMultiAgentFormatter(),
337+
)
338+
else:
339+
agent = ReActAgent(
340+
name=name,
341+
sys_prompt=Prompts.system_prompt.format(
342+
player_name=name,
343+
guidance=getattr(Prompts, f"notes_{role}"),
344+
),
345+
model=DashScopeChatModel(
346+
model_name="qwen3-max-preview",
347+
api_key=os.environ["DASHSCOPE_API_KEY"],
348+
enable_thinking=True,
349+
),
350+
formatter=DashScopeMultiAgentFormatter(),
351+
)
335352
# 获取对应角色的游戏指南
336353
role_notes = getattr(Prompts, f"notes_{role}", "")
337354

0 commit comments

Comments
 (0)