mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 09:16:22 +02:00
format with biome
This commit is contained in:
parent
77d49ca11c
commit
81ee04c2a5
21 changed files with 1602 additions and 1752 deletions
|
|
@ -1,98 +1,90 @@
|
|||
import { CreateLLMConfig, LLMConfig, UpdateLLMConfig } from "@/hooks/use-llm-configs";
|
||||
|
||||
export const fetchLLMConfigs = async (
|
||||
searchSpaceId: number,
|
||||
authToken: string
|
||||
) => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs?search_space_id=${searchSpaceId}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
export const fetchLLMConfigs = async (searchSpaceId: number, authToken: string) => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs?search_space_id=${searchSpaceId}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch LLM configurations");
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch LLM configurations");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const createLLMConfig = async (
|
||||
config: CreateLLMConfig,
|
||||
authToken: string
|
||||
config: CreateLLMConfig,
|
||||
authToken: string
|
||||
): Promise<LLMConfig | null> => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
body: JSON.stringify(config),
|
||||
}
|
||||
);
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
body: JSON.stringify(config),
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.detail || "Failed to create LLM configuration");
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.detail || "Failed to create LLM configuration");
|
||||
}
|
||||
|
||||
const newConfig = await response.json();
|
||||
const newConfig = await response.json();
|
||||
|
||||
return newConfig;
|
||||
return newConfig;
|
||||
};
|
||||
|
||||
export const deleteLLMConfig = async (
|
||||
id: number,
|
||||
authToken: string
|
||||
): Promise<boolean> => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
export const deleteLLMConfig = async (id: number, authToken: string): Promise<boolean> => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete LLM configuration");
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete LLM configuration");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const updateLLMConfig = async (
|
||||
id: number,
|
||||
config: UpdateLLMConfig,
|
||||
authToken: string
|
||||
id: number,
|
||||
config: UpdateLLMConfig,
|
||||
authToken: string
|
||||
): Promise<LLMConfig | null> => {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs/${id}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
body: JSON.stringify(config),
|
||||
}
|
||||
);
|
||||
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/llm-configs/${id}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
body: JSON.stringify(config),
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.detail || "Failed to update LLM configuration");
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.detail || "Failed to update LLM configuration");
|
||||
}
|
||||
|
||||
const updatedConfig = await response.json();
|
||||
|
||||
return updatedConfig;
|
||||
const updatedConfig = await response.json();
|
||||
|
||||
return updatedConfig;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue