MCPcopy Create free account
hub / github.com/answerlink/IntelliQ / send_message

Function send_message

utils/helpers.py:31–66  ·  view source on GitHub ↗

请求LLM函数

(message, user_input)

Source from the content-addressed store, hash-verified

29
30@lru_cache(maxsize=100)
31def send_message(message, user_input):
32 """
33 请求LLM函数
34 """
35 print('--------------------------------------------------------------------')
36 if config.DEBUG:
37 print('prompt输入:', message)
38 elif user_input:
39 print('用户输入:', user_input)
40 print('----------------------------------')
41 headers = {
42 "Authorization": f"Bearer {config.API_KEY}",
43 "Content-Type": "application/json",
44 }
45
46 data = {
47 "model": "gpt-3.5-turbo",
48 "messages": [
49 {"role": "system", "content": "You are a helpful assistant."},
50 {"role": "user", "content": f"{message}"}
51 ]
52 }
53
54 try:
55 response = requests.post(config.GPT_URL, headers=headers, json=data, verify=False)
56 if response.status_code == 200:
57 answer = response.json()["choices"][0]["message"]['content']
58 print('LLM输出:', answer)
59 print('--------------------------------------------------------------------')
60 return answer
61 else:
62 print(f"Error: {response.status_code}")
63 return None
64 except requests.RequestException as e:
65 print(f"Request error: {e}")
66 return None
67
68
69def is_slot_fully_filled(json_data):

Callers 5

recognize_intentMethod · 0.90
processMethod · 0.90
process_weather_sceneFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected