Documentation
¶
Overview ¶
Package websearch 公开资料检索抽象:接口可插拔,缺省实现 SearXNG 自建实例 (免 API key、零调用成本)。与 knowledge/rag 互补——本包面向外网公开资料。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Title string `json:"title"`
URL string `json:"url"`
Snippet string `json:"snippet"`
}
Result 单条检索结果。
type Searxng ¶
type Searxng struct {
BaseURL string
Language string // 缺省 "zh-CN";空串=不传 language 参数
DefaultTopK int // AsTool 用;≤0 兜底 5
HTTP *http.Client
}
Searxng SearXNG 自建实例客户端(GET /search?format=json——实例 settings.yml 须启用 formats: [html, json])。零 API key、零调用成本;商业后端后续按同 Service 接口接入。
func NewSearxng ¶
NewSearxng 构造(timeout 为单次检索上限;≤0 用 10s 兜底)。
func (*Searxng) AsTool ¶
AsTool 把检索包成 web_search 内置工具(与 rag.AsTool 同形态)。 AsTool 把检索包成 web_search 工具。
结果拼接前 Title/Snippet 过 fence.EscapeUntrusted(tools#49):检索结果是 半可信外网内容(敌意等级高于仓库内内容),未经消毒拼进编号列表会被 snippet 内嵌换行伪造条目与指令。
⚠️ panic 契约(oagentkit/rag#31 同族对齐):schema 反射构造失败时 panic (接口签名无 error 通道,「静态 schema 即编程错误」在此升级为显式 API 契约声明)。
Click to show internal directories.
Click to hide internal directories.