feat: AI问答限定只答本站功能
- 前端发送全站工具清单(按分类,实时), 后端系统提示限定只答站内功能 - 范围外问题礼貌拒绝并引导站内工具 - About功能介绍同步 验证: 站内OCR问题正常答; 站外写代码被拒并引导 ✓ CHANGELOG记录
This commit is contained in:
1 parent
baa17ec08b
commit
e9a7dcac15
4 files changed
+37
-2
No files matched your search
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. See [standa
|
||||
|
||||
## Version 2026.10.12-it-tools-pro
|
||||
|
||||
### 🤖 AI 问答限定只答本站功能
|
||||
- AI 问答改为只回答与本站功能/工具相关的问题(某功能在哪、怎么用、选哪个、功能区别)
|
||||
- 前端随请求发送**全站工具清单**(按分类、实时随工具增减),后端嵌入系统提示划定范围
|
||||
- 范围外问题(闲聊/写代码/天气/通用问答等)礼貌拒绝并引导提问站内功能
|
||||
- 验证:站内 OCR 问题正常作答(含分类+用法);站外"写冒泡排序"被拒绝并引导站内工具 ✓
|
||||
|
||||
|
||||
### 🎨 AI 生图:去图生图 + 适配全屏
|
||||
- 移除「图生图」模式(NEWAPI 无可用 i2i 通道),页面只保留文生图,去掉模式切换与图片上传
|
||||
- `ai-gen` 加入宽屏白名单(去 600px 限宽),页面占满屏幕宽度
|
||||
|
||||
@@ -1942,7 +1942,23 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not isinstance(history, list):
|
||||
history = []
|
||||
history = [m for m in history[-8:] if isinstance(m, dict) and m.get("role") in ("user", "assistant") and isinstance(m.get("content"), str)]
|
||||
messages = [{"role": "system", "content": "你是 IT-TOOLS-PRO 工具站的 AI 助手,用简体中文简洁、直接地回答,代码用代码块包裹。"}] + history + [{"role": "user", "content": prompt}]
|
||||
# 只回答本站功能:前端实时传入工具清单,嵌入系统提示限定作答范围
|
||||
catalog = str(payload.get("tools") or "").strip()[:6000]
|
||||
if not catalog:
|
||||
catalog = "(见站内左侧工具菜单)"
|
||||
system = (
|
||||
"你是 IT-TOOLS-PRO 工具站的专属 AI 助手。你只能回答与本站功能相关的问题。\n\n"
|
||||
"本站功能清单(按分类):\n" + catalog + "\n\n"
|
||||
"严格规则:\n"
|
||||
"1. 只回答上述清单范围内、与本站工具/功能有关的问题"
|
||||
"(例如:某功能在哪、怎么用、选哪个工具、功能区别、某工具能否完成某任务)。\n"
|
||||
"2. 对于清单范围之外的问题(闲聊、其他网站、通用知识问答、写代码、翻译句子、"
|
||||
"新闻天气、算命等),一律礼貌拒绝,"
|
||||
"并简短引导用户提问与本站功能相关的问题,可提示左侧菜单里的工具。\n"
|
||||
"3. 推荐工具时使用清单中的工具名称。\n"
|
||||
"4. 用简体中文简洁、直接地回答,代码用代码块包裹。"
|
||||
)
|
||||
messages = [{"role": "system", "content": system}] + history + [{"role": "user", "content": prompt}]
|
||||
key = os.environ.get("NEWAPI_KEY", "")
|
||||
upstream = os.environ.get("NEWAPI_URL", "http://192.168.68.19:3099/v1/chat/completions")
|
||||
model = os.environ.get("NEWAPI_MODEL", "big-pickle")
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
title: 'AI 智能',
|
||||
items: [
|
||||
{ name: 'AI 图片实验室', icon: 'AI', desc: '智能抠图去背景(本地模型)、AI 无损放大变清晰(2x/4x + 5 档降噪)、一键证件照(一寸/二寸/护照,白红蓝底),图片不上传服务器', tag: '全新' },
|
||||
{ name: 'AI 问答', icon: '问', desc: '多会话对话(新建/搜索/删除、自动命名)、支持多轮上下文、模型可选、对话登录后云端同步换电脑恢复', tag: '全新' },
|
||||
{ name: 'AI 问答', icon: '问', desc: '只回答本站功能相关问题(带全站工具清单、越界自动拒绝引导)、多会话对话、多轮上下文、模型可选、对话登录后云端同步换电脑恢复', tag: '全新' },
|
||||
{ name: '文案工具箱', icon: '文', desc: '一键改写、降 AIGC 率、爆款标题、小红书文案、朋友圈文案 5 大场景,模型可选 mimo / glm', tag: '全新' },
|
||||
{ name: '截图理解(AI 看图)', icon: '看', desc: '截图/票据/合同/报错图丢进去 AI 读懂并提取关键信息(多模态),金额日期编号原样保留,5 个预设问题', tag: '全新' },
|
||||
{ name: '视频字幕 AI', icon: '幕', desc: 'Whisper 本地转录生成 SRT、AI 一键翻译英日文、时间轴预览、SRT 下载,与视频工具箱联动', tag: '全新' },
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, ref } from 'vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getMachineId, licenseHeaders } from '@/tools/license/license';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
import { useToolStore } from '@/tools/tools.store';
|
||||
|
||||
useHead({ title: 'AI 问答 - IT-TOOLS-PRO' });
|
||||
const genHist = useGenHistory('ai-chat');
|
||||
|
||||
// 站点功能清单:随请求发给后端,AI 只围绕本站功能作答(实时、随工具增减自动更新)
|
||||
const toolStore = useToolStore();
|
||||
const { toolsByCategory } = storeToRefs(toolStore);
|
||||
const toolCatalog = computed(() =>
|
||||
toolsByCategory.value
|
||||
.map(c => `${c.name}:${c.components.map(t => t.name).join('、')}`)
|
||||
.join('\n'),
|
||||
);
|
||||
|
||||
interface ChatMsg {
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
@@ -147,6 +158,7 @@ async function send(text?: string) {
|
||||
prompt: content,
|
||||
model: model.value,
|
||||
history: conv.messages.slice(0, -1).slice(-8),
|
||||
tools: toolCatalog.value,
|
||||
}),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
|
||||
Reference in new issue
Block a user