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

Method completions

test/test_api/test_openai_api.py:70–85  ·  view source on GitHub ↗

文本补全

(self, prompt: str, **kwargs)

Source from the content-addressed store, hash-verified

68 raise Exception(f"API调用失败: {response.status_code} - {response.text}")
69
70 def completions(self, prompt: str, **kwargs) -> Dict[str, Any]:
71 """文本补全"""
72 data = {
73 "model": self.model_name,
74 "prompt": prompt,
75 "temperature": kwargs.get("temperature", 0.7),
76 "max_tokens": kwargs.get("max_tokens", 100),
77 **kwargs,
78 }
79
80 response = requests.post(f"{self.base_url}/v1/completions", headers=self.headers, json=data)
81
82 if response.status_code == 200:
83 return response.json()
84 else:
85 raise Exception(f"API调用失败: {response.status_code} - {response.text}")
86
87 def stream_completions(self, prompt: str, **kwargs):
88 """流式文本补全"""

Callers 1

test_completionsFunction · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected