添加 插件表单ai 能力

This commit is contained in:
zk
2026-05-11 11:06:25 +08:00
parent e8a094fd7b
commit 8c3f3b4f58
7 changed files with 212 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
+35
View File
@@ -0,0 +1,35 @@
"""表单填写 AI 生成模块
根据用户简历、岗位信息和表单字段,调 LLM 生成填写内容。
依赖:LLM 枚举、browser_plug/prompts
"""
from app.ai.browser_plug.prompts import FORM_FILL_SYSTEM_PROMPT
from app.ai.models import LLM
from app.core.logger import log
async def generate_form_answer(resume_text: str, job_text: str, agent_config_text: str,
label: str, reference: str | None, field_type: str) -> str:
"""生成表单字段的填写内容"""
system_content = FORM_FILL_SYSTEM_PROMPT.format(
resume_text=resume_text,
job_text=job_text,
agent_config_text=agent_config_text,
)
# 构造用户消息
user_parts = [f"表单字段:{label}", f"字段类型:{field_type}"]
if reference:
user_parts.append(f"参考信息:{reference}")
user_message = "\n".join(user_parts)
messages = [("system", system_content), ("human", user_message)]
try:
llm = LLM.DOUBAO_PRO_32K.create(temperature=0.3)
result = await llm.ainvoke(messages)
return result.content.strip()
except Exception as e:
log.error(f"表单填写AI调用失败: {e}")
raise ValueError("AI生成回答失败,请稍后重试")
+20
View File
@@ -0,0 +1,20 @@
"""浏览器插件 AI Prompt 模板"""
FORM_FILL_SYSTEM_PROMPT = """你是一个求职表单填写助手。根据用户的简历信息和岗位信息,为招聘网站的表单字段生成合适的填写内容。
【用户简历】
{resume_text}
【岗位信息】
{job_text}
【网申预设配置】
{agent_config_text}
【规则】
1. 根据表单字段的标签和类型,生成最合适的填写内容
2. 如果是选择题(select/radio/checkbox),必须从提供的选项中选择,返回选项原文
3. 如果是文本题(input/textarea),根据简历内容生成简洁、真实的回答
4. 不要编造简历中没有的信息
5. 回答要专业、得体,符合求职场景
6. 直接输出填写内容,不要任何解释、前缀或格式包裹"""