mirror of
https://github.com/cdryzun/tg_bot_collections.git
synced 2025-04-29 00:27:09 +08:00
fix: command
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
a0220fa8aa
commit
90fd74c403
@ -100,7 +100,8 @@ def wrap_handler(handler: T, bot: TeleBot) -> T:
|
|||||||
def wrapper(message: Message, *args: Any, **kwargs: Any) -> None:
|
def wrapper(message: Message, *args: Any, **kwargs: Any) -> None:
|
||||||
try:
|
try:
|
||||||
m = ""
|
m = ""
|
||||||
if message.text.find("answer_it") != -1:
|
|
||||||
|
if message.text and message.text.find("answer_it") != -1:
|
||||||
# for answer_it no args
|
# for answer_it no args
|
||||||
return handler(message, *args, **kwargs)
|
return handler(message, *args, **kwargs)
|
||||||
elif message.text is not None:
|
elif message.text is not None:
|
||||||
|
@ -220,6 +220,7 @@ if CHATGPT_API_KEY:
|
|||||||
bot.register_message_handler(
|
bot.register_message_handler(
|
||||||
chatgpt_photo_handler,
|
chatgpt_photo_handler,
|
||||||
content_types=["photo"],
|
content_types=["photo"],
|
||||||
func=lambda m: m.caption and m.caption.startswith(("gpt:", "/gpt")),
|
func=lambda m: m.caption
|
||||||
|
and m.caption.startswith(("gpt:", "/gpt", "gpt_pro:", "/gpt_pro")),
|
||||||
pass_bot=True,
|
pass_bot=True,
|
||||||
)
|
)
|
||||||
|
@ -160,39 +160,7 @@ def answer_it_handler(message: Message, bot: TeleBot):
|
|||||||
if chunk.choices[0].delta.content is None:
|
if chunk.choices[0].delta.content is None:
|
||||||
break
|
break
|
||||||
s += chunk.choices[0].delta.content
|
s += chunk.choices[0].delta.content
|
||||||
if time.time() - start > 1.2:
|
if time.time() - start > 1.5:
|
||||||
start = time.time()
|
|
||||||
bot_reply_markdown(reply_id, who, s, bot, split_text=False)
|
|
||||||
# maybe not complete
|
|
||||||
try:
|
|
||||||
bot_reply_markdown(reply_id, who, s, bot)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
bot_reply_markdown(reply_id, who, "answer wrong", bot)
|
|
||||||
|
|
||||||
##### Qwen #####
|
|
||||||
who = "Qwen Pro"
|
|
||||||
reply_id = bot_reply_first(latest_message, who, bot)
|
|
||||||
|
|
||||||
player_message = [{"role": "user", "content": m}]
|
|
||||||
|
|
||||||
try:
|
|
||||||
r = qwen_client.chat.completions.create(
|
|
||||||
messages=player_message,
|
|
||||||
max_tokens=4096,
|
|
||||||
model=QWEN_MODEL,
|
|
||||||
stream=True,
|
|
||||||
)
|
|
||||||
s = ""
|
|
||||||
start = time.time()
|
|
||||||
for chunk in r:
|
|
||||||
if chunk.choices[0].delta.content is None:
|
|
||||||
break
|
|
||||||
s += chunk.choices[0].delta.content
|
|
||||||
if time.time() - start > 1.2:
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
bot_reply_markdown(reply_id, who, s, bot, split_text=False)
|
bot_reply_markdown(reply_id, who, s, bot, split_text=False)
|
||||||
# maybe not complete
|
# maybe not complete
|
||||||
@ -206,7 +174,7 @@ def answer_it_handler(message: Message, bot: TeleBot):
|
|||||||
bot_reply_markdown(reply_id, who, "answer wrong", bot)
|
bot_reply_markdown(reply_id, who, "answer wrong", bot)
|
||||||
|
|
||||||
|
|
||||||
if GOOGLE_GEMINI_KEY and CHATGPT_API_KEY and QWEN_API_KEY:
|
if GOOGLE_GEMINI_KEY and CHATGPT_API_KEY:
|
||||||
|
|
||||||
def register(bot: TeleBot) -> None:
|
def register(bot: TeleBot) -> None:
|
||||||
bot.register_message_handler(md_handler, commands=["md"], pass_bot=True)
|
bot.register_message_handler(md_handler, commands=["md"], pass_bot=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user