测试带echo参数的文本补全
(self, prompt: str, echo: bool = True, **kwargs)
| 232 | raise Exception(f"API调用失败: {response.status_code} - {response.text}") |
| 233 | |
| 234 | def completions_with_echo(self, prompt: str, echo: bool = True, **kwargs) -> Dict[str, Any]: |
| 235 | """测试带echo参数的文本补全""" |
| 236 | data = { |
| 237 | "model": self.model_name, |
| 238 | "prompt": prompt, |
| 239 | "echo": echo, |
| 240 | "temperature": kwargs.get("temperature", 0.7), |
| 241 | "max_tokens": kwargs.get("max_tokens", 30), |
| 242 | **kwargs, |
| 243 | } |
| 244 | |
| 245 | response = requests.post(f"{self.base_url}/v1/completions", headers=self.headers, json=data) |
| 246 | |
| 247 | if response.status_code == 200: |
| 248 | return response.json() |
| 249 | else: |
| 250 | raise Exception(f"API调用失败: {response.status_code} - {response.text}") |
| 251 | |
| 252 | def completions_with_echo_and_logprobs( |
| 253 | self, prompt: str, echo: bool = True, logprobs: int = 5, **kwargs |