mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00: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;
|
||||
webSearch?: boolean;
|
||||
reasoning?: boolean;
|
||||
modelId?: string;
|
||||
contexts?: {
|
||||
docs: AIDocContextOption[];
|
||||
files: AIFileContextOption[];
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
})(),
|
||||
]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user