给 IP 检测加上 AI:场景咨询是怎么做的Adding AI to IP Detection: How Scenario Advice Works
多源数据聚合之后,信息是全了,但普通用户看不懂。ASN 是什么?BGP 走了哪条路?原生 IP 和广播 IP 有什么区别?这些概念对大多数人是黑话。After multi-source aggregation, the information was complete — but ordinary users couldn't read it.What's an ASN? Which BGP route? What's the difference between native and broadcas…
给 IP 检测加上 AI:场景咨询是怎么做的
后来增加了什么 / 技术选择 / 遇到的问题
为什么加 AI
多源数据聚合之后,信息是全了,但普通用户看不懂。
ASN 是什么?BGP 走了哪条路?原生 IP 和广播 IP 有什么区别?这些概念对大多数人是黑话。
AI 的价值在于翻译:把技术数据翻译成"人话",再给出行动建议。
场景咨询
v0.3.0 加了场景咨询。预设四个场景:
- Netflix:能不能看?是哪个区?
- 游戏:延迟怎么样?适合玩什么服?
- ChatGPT:能不能用?会不会被封?
- 跨境电商:IP 干净吗?适合做店铺吗?
外加一个自由输入框,想问什么直接问。
Prompt 设计
核心是一个系统提示词,硬性要求:
必须用简体中文回答 / MUST reply in English根据界面语言切换。续写时的提示词也要跟随语言——这个坑踩过一次:用户切到英文,AI 还在说中文。
Prompt 结构:
- 角色:网络分析师
- 输入:多源 IP 数据(JSON)
- 任务:综合分析 + 场景建议
- 格式:结论先行,再给细节
- 语言:跟随用户设置
流式输出
用 SSE 流式接收,打字机效果逐字显示。状态管理是个细节:
- 输入的草稿切页不丢
- 流式回答切页不丢
- 出错了显示友好文案,不甩原始报错
这些状态放在模块级的 store 里,不随组件卸载消失。
遇到的问题
问题 1:AI 胡说八道
大模型偶尔会编造数据。解法:Prompt 里明确"只基于提供的数据分析,不要推测没有的数据",并把原始数据展示在旁边,用户可以对照。
问题 2:更新检查报错
GitHub API 返回 404 或网络超时,原来直接展示原始 URL 和堆栈,用户看不懂。现在按错误类型映射成友好文案。
根据项目记录整理。部分细节待补充。
Adding AI to IP Detection: How Scenario Advice Works
What was added later / Tech choices / Problems encountered
Why Add AI
After multi-source aggregation, the information was complete — but ordinary users couldn't read it.
What's an ASN? Which BGP route? What's the difference between native and broadcast IP? These concepts are jargon to most people.
AI's value is translation: turning technical data into human language, then giving actionable advice.
Scenario Advice
v0.3.0 added scenario advice with four presets:
- Netflix: Can it stream? Which region?
- Gaming: How's the latency? Which server region suits it?
- ChatGPT: Does it work? Risk of ban?
- E-commerce: Is the IP clean? Good for running a store?
Plus a free-text box — ask anything.
Prompt Design
The core is a system prompt with hard requirements:
0
Following the UI language. The continuation prompt must follow too — learned this the hard way: user switches to English, AI keeps replying in Chinese.
Prompt structure:
- Role: network analyst
- Input: multi-source IP data (JSON)
- Task: comprehensive analysis + scenario advice
- Format: conclusion first, then details
- Language: follow user setting
Streaming Output
SSE streaming with typewriter effect. State management details:
- Draft input survives page switches
- Streaming answers survive page switches
- Errors show friendly messages, never raw stack traces
These live in a module-level store, not tied to component lifecycle.
Problems
Problem 1: AI hallucination
Models occasionally invent data. Fix: prompt explicitly says "analyze only based on provided data, don't speculate on missing data", and raw data is shown alongside for cross-checking.
Problem 2: Update check errors
GitHub API 404s or network timeouts used to dump raw URLs and stacks. Now mapped to friendly messages by error type.
Compiled from project records. Some details to be filled in.