MCPcopy Index your code
hub / github.com/ModelTC/LightLLM / simple_chat

Method simple_chat

test/test_api/test_openai_api.py:24–39  ·  view source on GitHub ↗

简单对话

(self, message: str, **kwargs)

Source from the content-addressed store, hash-verified

22 self.conversation_history = []
23
24 def simple_chat(self, message: str, **kwargs) -> Dict[str, Any]:
25 """简单对话"""
26 data = {
27 "model": self.model_name,
28 "messages": [{"role": "user", "content": message}],
29 "temperature": kwargs.get("temperature", 0.7),
30 "max_tokens": kwargs.get("max_tokens", 1000),
31 **kwargs,
32 }
33
34 response = requests.post(f"{self.base_url}/v1/chat/completions", headers=self.headers, json=data)
35
36 if response.status_code == 200:
37 return response.json()
38 else:
39 raise Exception(f"API调用失败: {response.status_code} - {response.text}")
40
41 def stream_chat(self, message: str, **kwargs):
42 data = {

Callers 1

test_simple_chatFunction · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected