mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
feat: added global llm configurations
This commit is contained in:
parent
48fca3329b
commit
d4345f75e5
24 changed files with 878 additions and 158 deletions
|
|
@ -12,8 +12,9 @@ export interface LLMConfig {
|
|||
api_base?: string;
|
||||
language?: string;
|
||||
litellm_params?: Record<string, any>;
|
||||
created_at: string;
|
||||
search_space_id: number;
|
||||
created_at?: string;
|
||||
search_space_id?: number;
|
||||
is_global?: boolean;
|
||||
}
|
||||
|
||||
export interface LLMPreferences {
|
||||
|
|
@ -283,3 +284,48 @@ export function useLLMPreferences(searchSpaceId: number | null) {
|
|||
isOnboardingComplete,
|
||||
};
|
||||
}
|
||||
|
||||
export function useGlobalLLMConfigs() {
|
||||
const [globalConfigs, setGlobalConfigs] = useState<LLMConfig[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const fetchGlobalConfigs = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/global-llm-configs`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem("surfsense_bearer_token")}`,
|
||||
},
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch global LLM configurations");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
setGlobalConfigs(data);
|
||||
setError(null);
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Failed to fetch global LLM configurations");
|
||||
console.error("Error fetching global LLM configurations:", err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchGlobalConfigs();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
globalConfigs,
|
||||
loading,
|
||||
error,
|
||||
refreshGlobalConfigs: fetchGlobalConfigs,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue