This agent is a test agent, which does nothing. (return empty string for each action)
| 95 | |
| 96 | |
| 97 | class FastChatAgent(AgentClient): |
| 98 | """This agent is a test agent, which does nothing. (return empty string for each action)""" |
| 99 | |
| 100 | def __init__( |
| 101 | self, |
| 102 | model_name, |
| 103 | controller_address=None, |
| 104 | worker_address=None, |
| 105 | temperature=0, |
| 106 | max_new_tokens=32, |
| 107 | top_p=0, |
| 108 | prompter=None, |
| 109 | args=None, |
| 110 | **kwargs, |
| 111 | ) -> None: |
| 112 | if controller_address is None and worker_address is None: |
| 113 | raise ValueError( |
| 114 | "Either controller_address or worker_address must be specified." |
| 115 | ) |
| 116 | self.controller_address = controller_address |
| 117 | self.worker_address = worker_address |
| 118 | self.model_name = model_name |
| 119 | self.temperature = temperature |
| 120 | self.max_new_tokens = max_new_tokens |
| 121 | self.top_p = top_p |
| 122 | self.prompter = Prompter.get_prompter(prompter) |
| 123 | self.args = args or {} |
| 124 | print(self.max_new_tokens) |
| 125 | super().__init__(**kwargs) |
| 126 | |
| 127 | def inference(self, history: List[dict]) -> str: |
| 128 | if self.worker_address: |
| 129 | worker_addr = self.worker_address |
| 130 | else: |
| 131 | controller_addr = self.controller_address |
| 132 | worker_addr = controller_addr |
| 133 | if worker_addr == "": |
| 134 | raise ValueError |
| 135 | gen_params = { |
| 136 | "model": self.model_name, |
| 137 | "temperature": self.temperature, |
| 138 | "max_new_tokens": self.max_new_tokens, |
| 139 | "echo": False, |
| 140 | "top_p": self.top_p, |
| 141 | **self.args, |
| 142 | } |
| 143 | if self.prompter: |
| 144 | prompt = self.prompter(history) |
| 145 | gen_params.update(prompt) |
| 146 | else: |
| 147 | conv = get_conversation_template(self.model_name) |
| 148 | for history_item in history: |
| 149 | role = history_item["role"] |
| 150 | content = history_item["content"] |
| 151 | if role == "user": |
| 152 | conv.append_message(conv.roles[0], content) |
| 153 | elif role == "agent": |
| 154 | conv.append_message(conv.roles[1], content) |
nothing calls this directly
no outgoing calls
no test coverage detected