feat: add deep think feature (#311)

* feat: implement backend logic

* feat: implement api/config endpoint

* rename the symbol

* feat: re-implement configuration at client-side

* feat: add client-side of deep thinking

* fix backend bug

* feat: add reasoning block

* docs: update readme

* fix: translate into English

* fix: change icon to lightbulb

* feat: ignore more bad cases

* feat: adjust thinking layout, and implement auto scrolling

* docs: add comments

---------

Co-authored-by: Henry Li <henry1943@163.com>
This commit is contained in:
DanielWalnut
2025-06-14 13:12:43 +08:00
committed by GitHub
parent a7315b46df
commit 19fa1e97c3
40 changed files with 2292 additions and 1102 deletions

View File

@@ -10,6 +10,7 @@ const SETTINGS_KEY = "deerflow.settings";
const DEFAULT_SETTINGS: SettingsState = {
general: {
autoAcceptedPlan: false,
enableDeepThinking: false,
enableBackgroundInvestigation: false,
maxPlanIterations: 1,
maxStepNum: 3,
@@ -24,6 +25,7 @@ const DEFAULT_SETTINGS: SettingsState = {
export type SettingsState = {
general: {
autoAcceptedPlan: boolean;
enableDeepThinking: boolean;
enableBackgroundInvestigation: boolean;
maxPlanIterations: number;
maxStepNum: number;
@@ -127,7 +129,9 @@ export const getChatStreamSettings = () => {
};
};
export function setReportStyle(value: "academic" | "popular_science" | "news" | "social_media") {
export function setReportStyle(
value: "academic" | "popular_science" | "news" | "social_media",
) {
useSettingsStore.setState((state) => ({
general: {
...state.general,
@@ -137,6 +141,16 @@ export function setReportStyle(value: "academic" | "popular_science" | "news" |
saveSettings();
}
export function setEnableDeepThinking(value: boolean) {
useSettingsStore.setState((state) => ({
general: {
...state.general,
enableDeepThinking: value,
},
}));
saveSettings();
}
export function setEnableBackgroundInvestigation(value: boolean) {
useSettingsStore.setState((state) => ({
general: {

View File

@@ -104,6 +104,7 @@ export async function sendMessage(
interrupt_feedback: interruptFeedback,
resources,
auto_accepted_plan: settings.autoAcceptedPlan,
enable_deep_thinking: settings.enableDeepThinking ?? false,
enable_background_investigation:
settings.enableBackgroundInvestigation ?? true,
max_plan_iterations: settings.maxPlanIterations,
@@ -132,6 +133,8 @@ export async function sendMessage(
role: data.role,
content: "",
contentChunks: [],
reasoningContent: "",
reasoningContentChunks: [],
isStreaming: true,
interruptFeedback,
};
@@ -296,6 +299,8 @@ export async function listenToPodcast(researchId: string) {
agent: "podcast",
content: JSON.stringify(podcastObject),
contentChunks: [],
reasoningContent: "",
reasoningContentChunks: [],
isStreaming: true,
};
appendMessage(podcastMessage);