feat(core): switch reasoning models by front-end (#12225)

Close [AI-116](https://linear.app/affine-design/issue/AI-116)
This commit is contained in:
akumatus
2025-05-13 09:54:20 +00:00
parent 74452a0aab
commit 39942a0d04
3 changed files with 7 additions and 1 deletions

View File

@@ -135,6 +135,7 @@ declare global {
isRootSession?: boolean; isRootSession?: boolean;
webSearch?: boolean; webSearch?: boolean;
reasoning?: boolean; reasoning?: boolean;
modelId?: string;
contexts?: { contexts?: {
docs: AIDocContextOption[]; docs: AIDocContextOption[];
files: AIFileContextOption[]; files: AIFileContextOption[];

View File

@@ -21,6 +21,7 @@ export type TextToTextOptions = {
postfix?: (text: string) => string; postfix?: (text: string) => string;
reasoning?: boolean; reasoning?: boolean;
webSearch?: boolean; webSearch?: boolean;
modelId?: string;
}; };
export type ToImageOptions = TextToTextOptions & { export type ToImageOptions = TextToTextOptions & {
@@ -117,6 +118,7 @@ export function textToText({
postfix, postfix,
reasoning, reasoning,
webSearch, webSearch,
modelId,
}: TextToTextOptions) { }: TextToTextOptions) {
let messageId: string | undefined; let messageId: string | undefined;
@@ -138,6 +140,7 @@ export function textToText({
messageId, messageId,
reasoning, reasoning,
webSearch, webSearch,
modelId,
}, },
workflow ? 'workflow' : undefined workflow ? 'workflow' : undefined
); );
@@ -199,6 +202,7 @@ export function textToText({
messageId, messageId,
reasoning, reasoning,
webSearch, webSearch,
modelId,
}); });
})(), })(),
]); ]);

View File

@@ -82,7 +82,7 @@ export function setupAIProvider(
//#region actions //#region actions
AIProvider.provide('chat', async options => { AIProvider.provide('chat', async options => {
const { input, contexts, webSearch } = options; const { input, contexts, webSearch, reasoning } = options;
const sessionId = await createSession({ const sessionId = await createSession({
promptName: 'Chat With AFFiNE AI', promptName: 'Chat With AFFiNE AI',
@@ -90,6 +90,7 @@ export function setupAIProvider(
}); });
return textToText({ return textToText({
...options, ...options,
modelId: options.modelId ?? (reasoning ? 'o4-mini' : undefined),
client, client,
sessionId, sessionId,
content: input, content: input,