Files
deer-flow/frontend/src/core/skills/api.ts
T
2026-01-31 11:08:27 +08:00

36 lines
837 B
TypeScript

import { getBackendBaseURL } from "@/core/config";
import type { Skill } from "./type";
export async function loadSkills() {
const skills = await fetch(`${getBackendBaseURL()}/api/skills`);
const json = await skills.json();
return json.skills as Skill[];
}
export async function enableSkill(skillName: string, enabled: boolean) {
const response = await fetch(
`${getBackendBaseURL()}/api/skills/${skillName}`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
enabled,
}),
},
);
return response.json();
}
export async function installSkill(skillName: string) {
const response = await fetch(
`${getBackendBaseURL()}/api/skills/${skillName}/install`,
{
method: "POST",
},
);
return response.json();
}