mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
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:
@@ -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[];
|
||||||
|
|||||||
@@ -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,
|
||||||
});
|
});
|
||||||
})(),
|
})(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user