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:
@@ -22,6 +22,7 @@ export async function* chatStream(
|
||||
max_step_num: number;
|
||||
max_search_results?: number;
|
||||
interrupt_feedback?: string;
|
||||
enable_deep_thinking?: boolean;
|
||||
enable_background_investigation: boolean;
|
||||
report_style?: "academic" | "popular_science" | "news" | "social_media";
|
||||
mcp_settings?: {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { type DeerFlowConfig } from "../config/types";
|
||||
|
||||
import { resolveServiceURL } from "./resolve-service-url";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__deerflowConfig: DeerFlowConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadConfig() {
|
||||
const res = await fetch(resolveServiceURL("./config"));
|
||||
const config = await res.json();
|
||||
return config;
|
||||
}
|
||||
|
||||
export function getConfig(): DeerFlowConfig {
|
||||
if (
|
||||
typeof window === "undefined" ||
|
||||
typeof window.__deerflowConfig === "undefined"
|
||||
) {
|
||||
throw new Error("Config not loaded");
|
||||
}
|
||||
return window.__deerflowConfig;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { env } from "~/env";
|
||||
import { useReplay } from "../replay";
|
||||
|
||||
import { fetchReplayTitle } from "./chat";
|
||||
import { getRAGConfig } from "./rag";
|
||||
import { getConfig } from "./config";
|
||||
|
||||
export function useReplayMetadata() {
|
||||
const { isReplay } = useReplay();
|
||||
@@ -52,15 +52,8 @@ export function useRAGProvider() {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
getRAGConfig()
|
||||
.then(setProvider)
|
||||
.catch((e) => {
|
||||
setProvider(null);
|
||||
console.error("Failed to get RAG provider", e);
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
setProvider(getConfig().rag.provider);
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
return { provider, loading };
|
||||
|
||||
@@ -10,15 +10,7 @@ export function queryRAGResources(query: string) {
|
||||
.then((res) => {
|
||||
return res.resources as Array<Resource>;
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(() => {
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
export function getRAGConfig() {
|
||||
return fetch(resolveServiceURL(`rag/config`), {
|
||||
method: "GET",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => res.provider);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface MessageChunkEvent
|
||||
"message_chunk",
|
||||
{
|
||||
content?: string;
|
||||
reasoning_content?: string;
|
||||
}
|
||||
> {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user