(self, dialog, n = 10)
| 245 | |
| 246 | |
| 247 | def infer_one_chat(self, dialog, n = 10): |
| 248 | prompt_tokens = self.format_chats(dialog)[0] |
| 249 | try: |
| 250 | if n <= 10: |
| 251 | outputs = self.model.generate(prompt_token_ids = prompt_tokens, sampling_params=self.sampling_params) |
| 252 | predictions = [] |
| 253 | for o in outputs[0].outputs: |
| 254 | predictions.append(o.text) |
| 255 | else: |
| 256 | iters = math.ceil(n/10) |
| 257 | predictions = [] |
| 258 | for i in range(0, iters): |
| 259 | outputs = self.model.generate(prompt, self.sampling_params) |
| 260 | for o in outputs[0].outputs: |
| 261 | predictions.append(o.text) |
| 262 | return predictions |
| 263 | except Exception as e: |
| 264 | logger.error("Error occurred with reason {} for prompt:\n{}".format(str(e), dialog[0]["content"])) |
| 265 | return str(e) |
| 266 | |
| 267 | |
| 268 |
no test coverage detected