(self, prompt, n = 20, temperature = 0.7)
| 124 | |
| 125 | @timeout_decorator.timeout(60) |
| 126 | def generate(self, prompt, n = 20, temperature = 0.7): |
| 127 | if not isinstance(prompt, list): |
| 128 | messages = self.build_messages(prompt) |
| 129 | else: |
| 130 | messages = prompt |
| 131 | |
| 132 | response = self.client.chat.completions.create( |
| 133 | model = self.model, |
| 134 | messages = messages, |
| 135 | temperature = temperature, |
| 136 | n = n, |
| 137 | ) |
| 138 | results = [] |
| 139 | for c in response.choices: |
| 140 | results.append(c.message.content) |
| 141 | return results |
| 142 | |
| 143 | |
| 144 | def run(self, prompt, times = 0, n = 20, temperature = 0.7): |
no test coverage detected