This commit is contained in:
HuangHai
2026-01-25 10:15:31 +08:00
parent 9071c0aa72
commit 291497d371
29 changed files with 35 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 93 KiB

View File

@@ -11,7 +11,7 @@ project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path:
sys.path.append(project_root)
from WeiXin.WxUtil import find_input_box_center, perform_input_action
from WeiXin.WxUtil import find_input_box_center, perform_input_action, analyze_chat_image
from Util.LlmUtil import get_llm_response
# 配置日志
@@ -37,10 +37,38 @@ async def generate_and_input():
d = u2.connect()
logger.info(f"设备连接成功: {d.info.get('serial')}")
# 2. 调用 LLM 生成回复
# 模拟一个简单的场景:针对之前的对话生成回复
prompt = "对方说:'AI 助手我现在可以开始和你聊天了!',请给出一个简短、友好且自然的回复,不超过 20 字。不要包含任何解释性文字。"
logger.info(f"正在请求 LLM 生成回复, Prompt: {prompt}")
# 2. 截图并识别对话历史
screenshot_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Screenshots")
if not os.path.exists(screenshot_dir):
os.makedirs(screenshot_dir)
tmp_shot = os.path.join(screenshot_dir, "t4_temp_history_check.jpg")
d.screenshot(tmp_shot)
analyzed_shot = os.path.join(screenshot_dir, "t4_temp_history_analyzed.jpg")
dialogue_log = analyze_chat_image(tmp_shot, analyzed_shot)
history_text = ""
if dialogue_log:
history_text = "\n".join(dialogue_log)
logger.info(f"提取到对话历史:\n{history_text}")
else:
logger.warning("未提取到对话历史")
history_text = "(无对话历史)"
# 3. 调用 LLM 生成回复
persona = (
"你是一名99年毕业,有27年教学经验的小学高级教师,大张老师。对作文批阅不下20000个,"
"非常熟悉小学阶段、初二以前的初中阶段作文教学。你的回复必须专业、严谨、沉稳且富有权威感。"
"严禁使用任何搞笑、幽默、有趣或轻浮的语气。要以资深教育者的身份给出严肃、务实的指导建议。"
)
prompt = (
f"人设:{persona}\n\n"
f"以下是微信聊天记录('对方'和'我'的对话):\n{history_text}\n\n"
"请作为大张老师,针对最后的消息给出一个简短、专业且严肃的回复,不超过 60 字。"
"禁止出现任何幽默或卖萌的词汇,保持特级教师的庄重感。直接输出回复内容,不要包含任何解释性文字。"
)
logger.info(f"正在以'严谨的大张老师'身份请求 LLM 生成回复...")
full_response = ""
async for chunk in get_llm_response(prompt, stream=False):
@@ -53,22 +81,14 @@ async def generate_and_input():
logger.error("LLM 生成内容为空,停止执行。")
return
# 3. 识别输入框位置
# 先截个图供识别使用
screenshot_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Screenshots")
if not os.path.exists(screenshot_dir):
os.makedirs(screenshot_dir)
tmp_shot = os.path.join(screenshot_dir, "t4_temp_input_check.jpg")
d.screenshot(tmp_shot)
# 4. 识别输入框位置
center_point, rect_box = find_input_box_center(tmp_shot)
if center_point:
cx, cy = center_point
logger.info(f"识别到输入框中心: ({cx}, {cy})")
# 4. 点击输入框并输入文字
# 5. 点击输入框并输入文字并发送
# 使用 WxUtil 中的 perform_input_action
# 该函数内部会先点击坐标,然后输入内容
# 设置 auto_send=True,输入文字后点击发送