Initial commit: deerflow-server (frontend-web + offline-backend-20260512)

This commit is contained in:
吉鑫升 committed 2026-05-13 09:36:15 +08:00
commit e7a455f22e
560 files changed
+101331

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import { getBackendBaseURL } from "../config";
import { apiFetch } from "../api";
import type { ModelsResponse } from "./types";
export async function loadModels(): Promise<ModelsResponse> {
const res = await apiFetch(`${getBackendBaseURL()}/api/models`);
const data = (await res.json()) as Partial<ModelsResponse>;
return {
models: data.models ?? [],
token_usage: data.token_usage ?? { enabled: false },
};
}
+18
View File
@@ -0,0 +1,18 @@
import { useQuery } from "@tanstack/react-query";
import { loadModels } from "./api";
export function useModels({ enabled = true }: { enabled?: boolean } = {}) {
const { data, isLoading, error } = useQuery({
queryKey: ["models"],
queryFn: () => loadModels(),
enabled,
refetchOnWindowFocus: false,
});
return {
models: data?.models ?? [],
tokenUsageEnabled: data?.token_usage.enabled ?? false,
isLoading,
error,
};
}
+2
View File
@@ -0,0 +1,2 @@
export * from "./api";
export * from "./types";
+18
View File
@@ -0,0 +1,18 @@
export interface Model {
id: string;
name: string;
model: string;
display_name: string;
description?: string | null;
supports_thinking?: boolean;
supports_reasoning_effort?: boolean;
}
export interface TokenUsageSettings {
enabled: boolean;
}
export interface ModelsResponse {
models: Model[];
token_usage: TokenUsageSettings;
}