import type { AppType } from "@tavern/functions/src/stableDiffusion";
import { hc } from "hono/client";
import { Resource } from "sst";
const client = hc<AppType>(Resource.StableDiffusion.url);
export const getImageGenerationModels = async () => {
let error = "";
const res = await client.models
.$get()
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ("detail" in err) {
error = err.detail;
} else {
error = "Server connection failed";
}
return null;
});
if (error) {
throw error;
}
return res;
};
import type { AppType } from "@tavern/functions/src/stableDiffusion";
import { hc } from "hono/client";
import { Resource } from "sst";
const client = hc<AppType>(Resource.StableDiffusion.url);
export const getImageGenerationModels = async () => {
let error = "";
const res = await client.models
.$get()
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ("detail" in err) {
error = err.detail;
} else {
error = "Server connection failed";
}
return null;
});
if (error) {
throw error;
}
return res;
};