feat: load function from url

This commit is contained in:
Timothy Jaeryang Baek
2025-05-26 23:52:22 +04:00
parent 7d756982c2
commit b4caad928e
5 changed files with 271 additions and 5 deletions

View File

@@ -62,6 +62,40 @@ export const getFunctions = async (token: string = '') => {
return res;
};
export const loadFunctionByUrl = async (token: string = '', url: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/functions/load/url`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: `Bearer ${token}`
},
body: JSON.stringify({
url
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err.detail;
console.error(err);
return null;
});
if (error) {
throw error;
}
return res;
};
export const exportFunctions = async (token: string = '') => {
let error = null;