|
@@ -13,11 +13,11 @@ max_pic_see = 1
|
|
|
|
|
|
prompt_pic = config_get("prompt_pic")
|
|
|
prompt_lora = config_get("prompt_lora")
|
|
|
+prompt_chpic = config_get("prompt_chpic")
|
|
|
|
|
|
pro_good = "solo,cat ears,black_hair,black_eye,"
|
|
|
pro_bad = config_get("pro_bad")
|
|
|
|
|
|
-openrouter_key = key_get("openrouter")
|
|
|
groq_key = key_get("groq")
|
|
|
siliflow_key = key_get("siliflow")
|
|
|
|
|
@@ -59,7 +59,7 @@ def AI_chat(group_id ,word ,prompt):
|
|
|
try:
|
|
|
ans = groq_chat(messages)
|
|
|
except Exception as e:
|
|
|
- ans = chat_deepseek_r1(messages)
|
|
|
+ ans = siliflow_chat(messages)
|
|
|
ans = ans.lstrip()
|
|
|
ans = ans.lstrip("猫猫:")
|
|
|
while True:
|
|
@@ -69,33 +69,7 @@ def AI_chat(group_id ,word ,prompt):
|
|
|
break
|
|
|
return ans
|
|
|
|
|
|
-def chat_deepseek_r1(messages):
|
|
|
- """
|
|
|
- 备用对话通道,https://openrouter.ai/api/v1
|
|
|
- """
|
|
|
- client = OpenAI(
|
|
|
- base_url="https://openrouter.ai/api/v1",
|
|
|
- api_key=openrouter_key,
|
|
|
- )
|
|
|
-
|
|
|
- model2 = "deepseek/deepseek-r1-distill-llama-70b:free"
|
|
|
- model = "deepseek/deepseek-r1:free"
|
|
|
-
|
|
|
- completion = client.chat.completions.create(
|
|
|
- extra_headers={
|
|
|
- "HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
|
|
|
- "X-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
|
|
|
- },
|
|
|
- model=model2,
|
|
|
- stream=False,
|
|
|
- messages=messages
|
|
|
- )
|
|
|
-
|
|
|
- ans = completion.choices[0].message.content
|
|
|
-
|
|
|
- return ans
|
|
|
-
|
|
|
-def groq_chat(messages):
|
|
|
+def groq_chat(messages, model = "deepseek-r1-distill-llama-70b"):
|
|
|
"""
|
|
|
主对话通道,https://api.gxx12138.space/groq/v1
|
|
|
"""
|
|
@@ -104,8 +78,6 @@ def groq_chat(messages):
|
|
|
api_key=groq_key
|
|
|
)
|
|
|
|
|
|
- model = "deepseek-r1-distill-llama-70b"
|
|
|
-
|
|
|
completion = client.chat.completions.create(
|
|
|
model=model,
|
|
|
stream=False,
|
|
@@ -116,7 +88,7 @@ def groq_chat(messages):
|
|
|
|
|
|
return ans
|
|
|
|
|
|
-def siliflow_chat(messages):
|
|
|
+def siliflow_chat(messages, model = "THUDM/glm-4-9b-chat"):
|
|
|
"""
|
|
|
备用对话通道,https://api.siliconflow.cn/v1'
|
|
|
"""
|
|
@@ -129,7 +101,7 @@ def siliflow_chat(messages):
|
|
|
# 发送AI请求
|
|
|
# THUDM/glm-4-9b-chat google/gemma-2-9b-it
|
|
|
response = client.chat.completions.create(
|
|
|
- model="THUDM/glm-4-9b-chat",
|
|
|
+ model=model,
|
|
|
messages=messages,
|
|
|
stream=False,
|
|
|
temperature=0.8,
|
|
@@ -141,7 +113,6 @@ def siliflow_chat(messages):
|
|
|
|
|
|
return ans
|
|
|
|
|
|
-# 根据群聊内近4条消息获取绘画提示词
|
|
|
def AI_get_picprompt(group_id):
|
|
|
"""
|
|
|
群聊id自动获取群聊记录来获取绘画提示词
|
|
@@ -160,6 +131,27 @@ def AI_get_picprompt(group_id):
|
|
|
ans = groq_chat(messages)
|
|
|
return pro_good + ans.strip().replace("\n", "") + ","
|
|
|
|
|
|
+def AI_sendphoto_ornot(event):
|
|
|
+ """
|
|
|
+ AI思考链,判断是否应该发送图片
|
|
|
+ """
|
|
|
+ messages = [{'role': 'system', 'content': prompt_chpic}]
|
|
|
+ messages.append({'role': 'user', 'content': event})
|
|
|
+ client = OpenAI(
|
|
|
+ base_url='https://api.siliconflow.cn/v1',
|
|
|
+ api_key=siliflow_key
|
|
|
+ )
|
|
|
+ # 发送AI请求
|
|
|
+ response = client.chat.completions.create(
|
|
|
+ model="THUDM/glm-4-9b-chat",
|
|
|
+ messages=messages,
|
|
|
+ stream=False,
|
|
|
+ temperature=0.7,
|
|
|
+ )
|
|
|
+ ans = response.choices[0].message.content
|
|
|
+ ans = ans.lstrip()
|
|
|
+ print(f"图片发送决定:{ans}")
|
|
|
+ return ans
|
|
|
|
|
|
def AI_lora_getpic_prompt(word):
|
|
|
"""
|
|
@@ -169,4 +161,10 @@ def AI_lora_getpic_prompt(word):
|
|
|
messages = [{'role': 'system', 'content': prompt_lora}]
|
|
|
messages.append({'role': 'user', 'content': word})
|
|
|
ans = siliflow_chat(messages).replace(", ", ",")
|
|
|
- return ans.strip().replace("\n", "") + ","
|
|
|
+ return ans.strip().replace("\n", "") + ","
|
|
|
+
|
|
|
+def detect_tool(message):
|
|
|
+ """
|
|
|
+ 新方法,编写中
|
|
|
+ """
|
|
|
+ model = "llama-3.3-70b-versatile"
|