Skip to content

Conversation

@dingyi222666
Copy link
Member

This PR fixes several issues in the search-service package that were causing errors in browser mode.

Bug fixes

  • Fix typo: mulitSourceModemultiSourceMode in config schema and usage
  • Fix model reference issues with proper null checking using optional chaining
  • Update SearchTool to use ComputedRef<ChatLunaChatModel> for proper type safety
  • Fix browserModelRef usage in web_search tool registration

Other Changes

  • Bump package version to 1.3.0-alpha.0 for next development cycle

Closes #561

- Fix typo: mulitSourceMode → multiSourceMode in config and usage
- Fix model reference with proper null checking using optional chaining
- Update SearchTool to use ComputedRef<ChatLunaChatModel> for type safety
- Fix browserModelRef usage in web_search tool registration

Closes #561
Increment package version for next development cycle
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

本次变更统一改用计算引用获取摘要模型,修正配置字段名 mulitSourceMode→multiSourceMode,并在多源限制计算中使用正确字段。搜索工具的 LLM 改为 ComputedRef 访问。多处调用改为使用 ?.value 进行空安全访问与传递。

Changes

Cohort / File(s) Summary
模型引用与浏览器工具调整
packages/search-service/src/index.ts
引入 browserModelRefkeywordExtractModel?.value 派生;在 web_search 路径用 browserModelRef 替代直接模型;web_browser 内新增 summaryModel(来源 keywordExtractModel?.value ?? params.model),并在 PuppeteerBrowserTool 构造中使用;相关调用统一改为空安全访问与新引用。
配置字段更名与使用修正
packages/search-service/src/index.ts, packages/search-service/src/provide.ts
将公开 Config 字段 mulitSourceMode 更名为 multiSourceMode;同步更新 Schema 类型与默认映射;在多源信号上限计算中使用 this.config.multiSourceMode 驱动平均分配或总量路径。
搜索工具 LLM 访问方式
packages/search-service/src/tools/search.ts
SearchToolllm 类型改为 ComputedRef<ChatLunaChatModel>;构造与内部访问改为 this.llm?.value;更新导入与 generateFakeSearchResult 调用。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant Chain as BrowsingChain
  participant Cfg as Config
  participant Models as ModelRefs
  participant Tool as PuppeteerBrowserTool

  User->>Chain: 切换到浏览模式
  Chain->>Models: 读取 keywordExtractModel?.value
  alt 有提取模型
    Models-->>Chain: 返回模型
  else 无提取模型
    Chain-->>Chain: 使用 params.model 作为 summaryModel
  end
  Chain->>Tool: 构造时传入 summaryModel(Computed/Ref)
  Note over Tool: 内部通过 .value 读取模型
  Tool-->>User: 执行浏览与摘要
Loading
sequenceDiagram
  autonumber
  participant Cfg as Config
  participant Prov as ProviderManager

  Cfg-->>Prov: multiSourceMode, limit
  alt multiSourceMode == "average"
    Prov-->>Prov: signalLimit = limit / providers
  else multiSourceMode == "total"
    Prov-->>Prov: signalLimit = limit
  end
  Prov-->>Prov: 按 signalLimit 分发请求
Loading
sequenceDiagram
  autonumber
  participant Search as SearchTool
  participant LLM as ComputedRef<ChatModel>

  Search->>LLM: 访问 llm?.value
  alt value 存在
    LLM-->>Search: ChatModel
    Search-->>Search: 生成/伪造搜索结果
  else value 为空
    Search-->>Search: 走空安全分支(避免读取 null.value)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

我在终端草地蹦又跳,
把 mulit 的字母轻轻校,
模型改为引用抱怀抱,
?.value 防止空指尖乱跑。
多源分配各自一小勺,
浏览链路顺畅不再闹。
啦啦——兔耳随提交轻摇 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/search-service

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f08420 and a816545.

⛔ Files ignored due to path filters (1)
  • packages/search-service/package.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • packages/search-service/src/index.ts (5 hunks)
  • packages/search-service/src/provide.ts (1 hunks)
  • packages/search-service/src/tools/search.ts (3 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dingyi222666 dingyi222666 merged commit c3f2cbc into v1-dev Sep 28, 2025
2 of 3 checks passed
@dingyi222666 dingyi222666 deleted the fix/search-service branch September 28, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 切换到浏览模式持续报错

2 participants