mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor(core): use the websearch parameters passed in by the front-end (#11989)
Support [AI-60](https://linear.app/affine-design/issue/AI-60). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated naming conventions for the web search tool to ensure consistency across AI chat features. - Simplified internal handling of web search tool options for a more streamlined experience. - Unified parameter naming from "mustSearch" to "webSearch" across AI chat inputs and actions. - **Chores** - Removed unused configuration options related to web search from prompt settings. - Added support for enabling or disabling web search via new parameters in chat requests. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -179,12 +179,16 @@ export class CopilotController implements BeforeApplicationShutdown {
|
||||
const reasoning = Array.isArray(params.reasoning)
|
||||
? Boolean(params.reasoning[0])
|
||||
: Boolean(params.reasoning);
|
||||
const webSearch = Array.isArray(params.webSearch)
|
||||
? Boolean(params.webSearch[0])
|
||||
: Boolean(params.webSearch);
|
||||
|
||||
delete params.messageId;
|
||||
delete params.retry;
|
||||
delete params.reasoning;
|
||||
delete params.webSearch;
|
||||
|
||||
return { messageId, retry, reasoning, params };
|
||||
return { messageId, retry, reasoning, webSearch, params };
|
||||
}
|
||||
|
||||
private getSignal(req: Request) {
|
||||
@@ -232,7 +236,8 @@ export class CopilotController implements BeforeApplicationShutdown {
|
||||
const info: any = { sessionId, params };
|
||||
|
||||
try {
|
||||
const { messageId, retry, reasoning } = this.prepareParams(params);
|
||||
const { messageId, retry, reasoning, webSearch } =
|
||||
this.prepareParams(params);
|
||||
|
||||
const provider = await this.chooseTextProvider(
|
||||
user.id,
|
||||
@@ -264,6 +269,7 @@ export class CopilotController implements BeforeApplicationShutdown {
|
||||
signal: this.getSignal(req),
|
||||
user: user.id,
|
||||
reasoning,
|
||||
webSearch,
|
||||
});
|
||||
|
||||
session.push({
|
||||
@@ -296,7 +302,8 @@ export class CopilotController implements BeforeApplicationShutdown {
|
||||
const info: any = { sessionId, params, throwInStream: false };
|
||||
|
||||
try {
|
||||
const { messageId, retry, reasoning } = this.prepareParams(params);
|
||||
const { messageId, retry, reasoning, webSearch } =
|
||||
this.prepareParams(params);
|
||||
|
||||
const provider = await this.chooseTextProvider(
|
||||
user.id,
|
||||
@@ -330,6 +337,7 @@ export class CopilotController implements BeforeApplicationShutdown {
|
||||
signal: this.getSignal(req),
|
||||
user: user.id,
|
||||
reasoning,
|
||||
webSearch,
|
||||
})
|
||||
).pipe(
|
||||
connect(shared$ =>
|
||||
|
||||
Reference in New Issue
Block a user