mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-20 21:04:45 +08:00
feat: support dynamic loading models
This commit is contained in:
9
frontend/src/core/models/api.ts
Normal file
9
frontend/src/core/models/api.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getBackendBaseURL } from "../config";
|
||||
|
||||
import type { Model } from "./types";
|
||||
|
||||
export async function loadModels() {
|
||||
const res = fetch(`${getBackendBaseURL()}/api/models`);
|
||||
const { models } = (await (await res).json()) as { models: Model[] };
|
||||
return models;
|
||||
}
|
||||
11
frontend/src/core/models/hooks.ts
Normal file
11
frontend/src/core/models/hooks.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { loadModels } from "./api";
|
||||
|
||||
export function useModels() {
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ["models"],
|
||||
queryFn: () => loadModels(),
|
||||
});
|
||||
return { models: data ?? [], isLoading, error };
|
||||
}
|
||||
2
frontend/src/core/models/index.ts
Normal file
2
frontend/src/core/models/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./api";
|
||||
export * from "./types";
|
||||
7
frontend/src/core/models/types.ts
Normal file
7
frontend/src/core/models/types.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export interface Model {
|
||||
id: string;
|
||||
name: string;
|
||||
display_name: string;
|
||||
description?: string | null;
|
||||
supports_thinking?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user