structured_output_cn.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # -*- coding: utf-8 -*-
  2. """三国狼人杀游戏的结构化输出模型"""
  3. from typing import Literal, Optional, List
  4. from pydantic import BaseModel, Field
  5. from agentscope.agent import AgentBase
  6. class DiscussionModelCN(BaseModel):
  7. """中文版讨论输出格式"""
  8. reach_agreement: bool = Field(
  9. description="是否已达成一致意见",
  10. )
  11. confidence_level: int = Field(
  12. description="对当前推理的信心程度(1-10)",
  13. ge=1, le=10
  14. )
  15. key_evidence: Optional[str] = Field(
  16. description="支持你观点的关键证据",
  17. default=None
  18. )
  19. def get_vote_model_cn(agents: list[AgentBase]) -> type[BaseModel]:
  20. """获取中文版投票模型"""
  21. class VoteModelCN(BaseModel):
  22. """中文版投票输出格式"""
  23. vote: Literal[tuple(_.name for _ in agents)] = Field(
  24. description="你要投票淘汰的玩家姓名",
  25. )
  26. reason: str = Field(
  27. description="投票理由,简要说明为什么选择此人",
  28. )
  29. suspicion_level: int = Field(
  30. description="对被投票者的怀疑程度(1-10)",
  31. ge=1, le=10
  32. )
  33. return VoteModelCN
  34. class WitchActionModelCN(BaseModel):
  35. """中文版女巫行动模型"""
  36. use_antidote: bool = Field(
  37. description="是否使用解药救人",
  38. default=False
  39. )
  40. use_poison: bool = Field(
  41. description="是否使用毒药杀人",
  42. default=False
  43. )
  44. target_name: Optional[str] = Field(
  45. description="目标玩家姓名(救人或毒杀的对象)",
  46. default=None
  47. )
  48. action_reason: Optional[str] = Field(
  49. description="行动理由",
  50. default=None
  51. )
  52. def get_seer_model_cn(agents: list[AgentBase]) -> type[BaseModel]:
  53. """获取中文版预言家模型"""
  54. class SeerModelCN(BaseModel):
  55. """中文版预言家查验格式"""
  56. target: Literal[tuple(_.name for _ in agents)] = Field(
  57. description="要查验的玩家姓名",
  58. )
  59. check_reason: str = Field(
  60. description="查验此人的原因",
  61. )
  62. priority_level: int = Field(
  63. description="查验优先级(1-10)",
  64. ge=1, le=10
  65. )
  66. return SeerModelCN
  67. def get_hunter_model_cn(agents: list[AgentBase]) -> type[BaseModel]:
  68. """获取中文版猎人模型"""
  69. class HunterModelCN(BaseModel):
  70. """中文版猎人开枪格式"""
  71. shoot: bool = Field(
  72. description="是否使用开枪技能",
  73. )
  74. target: Optional[Literal[tuple(_.name for _ in agents)]] = Field(
  75. description="开枪目标玩家姓名",
  76. default=None
  77. )
  78. shoot_reason: Optional[str] = Field(
  79. description="开枪理由",
  80. default=None
  81. )
  82. return HunterModelCN
  83. class WerewolfKillModelCN(BaseModel):
  84. """中文版狼人击杀模型"""
  85. target: str = Field(
  86. description="要击杀的玩家姓名",
  87. )
  88. kill_strategy: str = Field(
  89. description="击杀策略说明",
  90. )
  91. team_coordination: Optional[str] = Field(
  92. description="与狼队友的配合计划",
  93. default=None
  94. )
  95. class GameAnalysisModelCN(BaseModel):
  96. """中文版游戏分析模型"""
  97. suspected_werewolves: List[str] = Field(
  98. description="怀疑的狼人名单",
  99. default_factory=list
  100. )
  101. trusted_players: List[str] = Field(
  102. description="信任的玩家名单",
  103. default_factory=list
  104. )
  105. key_clues: List[str] = Field(
  106. description="关键线索列表",
  107. default_factory=list
  108. )
  109. next_strategy: str = Field(
  110. description="下一步策略",
  111. )