Update app.py
Browse files
app.py
CHANGED
@@ -53,13 +53,12 @@ BOT_COMMANDS = [
|
|
53 |
]
|
54 |
DEFAULT_TEMP = 1.5
|
55 |
|
56 |
-
# 工具定义
|
57 |
TOOLS = [
|
58 |
{
|
59 |
"type": "function",
|
60 |
"function": {
|
61 |
"name": "get_current_datetime",
|
62 |
-
"description": "
|
63 |
"parameters": {
|
64 |
"type": "object",
|
65 |
"properties": {},
|
@@ -70,12 +69,10 @@ TOOLS = [
|
|
70 |
]
|
71 |
|
72 |
def get_current_datetime():
|
73 |
-
"""获取当前的日期和时间,并返回UTC+8时区的时间。"""
|
74 |
utc_time = datetime.now(timezone.utc)
|
75 |
local_time = utc_time.astimezone(timezone(timedelta(hours=8)))
|
76 |
return local_time.strftime("%Y-%m-%d %H:%M:%S")
|
77 |
|
78 |
-
|
79 |
def make_telegram_request(method, data=None):
|
80 |
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/{method}"
|
81 |
if PHP_PROXY_URL:
|
@@ -206,7 +203,6 @@ def parseCommand(userMessage):
|
|
206 |
command = command.split('@')[0]
|
207 |
return command[1:]
|
208 |
|
209 |
-
|
210 |
async def handlePrivateCommand(chatId, userMessage, fromUserId, isGroupChat):
|
211 |
command = parseCommand(userMessage)
|
212 |
if userMessage.startswith('/settemp '):
|
@@ -285,7 +281,6 @@ async def processAiMessage(chatId, userMessage, fromUserId, message_id):
|
|
285 |
print(f'处理消息时发生错误: {error}')
|
286 |
await editTelegramMessage(chatId, thinking_message_id, '处理消息时发生错误,请稍后再试')
|
287 |
|
288 |
-
|
289 |
async def handleAiResponse(ai_data, chatId, history, thinking_message_id):
|
290 |
if ai_data and ai_data.get('choices') and len(ai_data['choices']) > 0:
|
291 |
choice = ai_data['choices'][0]
|
@@ -332,7 +327,6 @@ async def handleAiResponse(ai_data, chatId, history, thinking_message_id):
|
|
332 |
|
333 |
return 'AI 返回了无法识别的格式'
|
334 |
|
335 |
-
|
336 |
async def handleCallbackQuery(callbackQuery):
|
337 |
chatId = callbackQuery['message']['chat']['id']
|
338 |
data = callbackQuery['data']
|
|
|
53 |
]
|
54 |
DEFAULT_TEMP = 1.5
|
55 |
|
|
|
56 |
TOOLS = [
|
57 |
{
|
58 |
"type": "function",
|
59 |
"function": {
|
60 |
"name": "get_current_datetime",
|
61 |
+
"description": "获取当前的日期和时间",
|
62 |
"parameters": {
|
63 |
"type": "object",
|
64 |
"properties": {},
|
|
|
69 |
]
|
70 |
|
71 |
def get_current_datetime():
|
|
|
72 |
utc_time = datetime.now(timezone.utc)
|
73 |
local_time = utc_time.astimezone(timezone(timedelta(hours=8)))
|
74 |
return local_time.strftime("%Y-%m-%d %H:%M:%S")
|
75 |
|
|
|
76 |
def make_telegram_request(method, data=None):
|
77 |
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/{method}"
|
78 |
if PHP_PROXY_URL:
|
|
|
203 |
command = command.split('@')[0]
|
204 |
return command[1:]
|
205 |
|
|
|
206 |
async def handlePrivateCommand(chatId, userMessage, fromUserId, isGroupChat):
|
207 |
command = parseCommand(userMessage)
|
208 |
if userMessage.startswith('/settemp '):
|
|
|
281 |
print(f'处理消息时发生错误: {error}')
|
282 |
await editTelegramMessage(chatId, thinking_message_id, '处理消息时发生错误,请稍后再试')
|
283 |
|
|
|
284 |
async def handleAiResponse(ai_data, chatId, history, thinking_message_id):
|
285 |
if ai_data and ai_data.get('choices') and len(ai_data['choices']) > 0:
|
286 |
choice = ai_data['choices'][0]
|
|
|
327 |
|
328 |
return 'AI 返回了无法识别的格式'
|
329 |
|
|
|
330 |
async def handleCallbackQuery(callbackQuery):
|
331 |
chatId = callbackQuery['message']['chat']['id']
|
332 |
data = callbackQuery['data']
|