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;
webSearch?: boolean;
reasoning?: boolean;
modelId?: string;
contexts?: {
docs: AIDocContextOption[];
files: AIFileContextOption[];

View File

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

View File

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