MCPcopy
hub / github.com/ModelTC/LightLLM / completions_with_echo

Method completions_with_echo

test/test_api/test_openai_api.py:234–250  ·  view source on GitHub ↗

测试带echo参数的文本补全

(self, prompt: str, echo: bool = True, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 1

test_echoFunction · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected