(self,
api_key: str,
name: str,
agent_goal: str,
agent_description: str,
get_agent_state_fn: Callable,
workers: Optional[List[WorkerConfig]] = None,
)
| 45 | |
| 46 | class Agent: |
| 47 | def __init__(self, |
| 48 | api_key: str, |
| 49 | name: str, |
| 50 | agent_goal: str, |
| 51 | agent_description: str, |
| 52 | get_agent_state_fn: Callable, |
| 53 | workers: Optional[List[WorkerConfig]] = None, |
| 54 | ): |
| 55 | |
| 56 | self._base_url: str = "https://game.virtuals.io" |
| 57 | self._api_key: str = api_key |
| 58 | |
| 59 | # checks |
| 60 | if not self._api_key: |
| 61 | raise ValueError("API key not set") |
| 62 | |
| 63 | # initialize session |
| 64 | self._session = Session() |
| 65 | |
| 66 | self.name = name |
| 67 | self.agent_goal = agent_goal |
| 68 | self.agent_description = agent_description |
| 69 | |
| 70 | # set up workers |
| 71 | if workers is not None: |
| 72 | self.workers = {w.id: w for w in workers} |
| 73 | else: |
| 74 | self.workers = {} |
| 75 | self.current_worker_id = None |
| 76 | |
| 77 | # get agent/task generator state function |
| 78 | self.get_agent_state_fn = get_agent_state_fn |
| 79 | |
| 80 | # initialize and set up agent states |
| 81 | self.agent_state = self.get_agent_state_fn(None, None) |
| 82 | |
| 83 | # create agent |
| 84 | self.agent_id = create_agent( |
| 85 | self._base_url, self._api_key, self.name, self.agent_description, self.agent_goal |
| 86 | ) |
| 87 | |
| 88 | def compile(self): |
| 89 | """ Compile the workers for the agent - i.e. set up task generator""" |
nothing calls this directly
no test coverage detected