Skip to content

Commit

Permalink
bugfix load civitai model by url
Browse files Browse the repository at this point in the history
  • Loading branch information
6174 committed Jun 20, 2024
1 parent 59eff30 commit 4c126a6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/node/src/modules/model-manager/civitai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function searchCivitModelFromSHA256(sha256: string) {

export async function getCivitModelById(modelId: string) {
const headers = resolveCivitHeaders();
const ret = await proxyFetch(`https://api.civitai.com/v1/model?modelId=${modelId}`, {
const ret = await proxyFetch(`https://api.civitai.com/v1/models/${modelId}`, {
headers,
})
const data = await ret.json()
Expand Down
2 changes: 1 addition & 1 deletion apps/node/src/routes/api/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function ApiEnvCheck(req: Request, res: Response) {
success: false,
error: err.message + err.stack
})
}
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions apps/node/src/routes/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export async function ApiRouteInstallModel(req: Request, res: Response) {
export async function ApiGetCivitaiModels(req: Request, res: Response) {
try {
const params = req.body
console.log("modelId", params);
if (params.modelId) {
const ret = await getCivitModelById(params.modelId)
res.send({
Expand All @@ -106,6 +107,7 @@ export async function ApiGetCivitaiModels(req: Request, res: Response) {
});
return
}

if (params.hash) {
const ret = await getCivitModelByHash(params.hash)
res.send({
Expand Down
2 changes: 1 addition & 1 deletion packages/common/store/model.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ async function getCivitModels(currentPage: number, pageSize: number, filters: an
}

export const getCivitModelByModelId = _.memoize(async (modelId: string): Promise<CivitAIModel> => {
const api = getBackendUrl("/api/civit/models");
const api = getBackendUrl("/api/civitai/models");
const ret = await fetch(api, {
method: "POST",
headers: {
Expand Down

0 comments on commit 4c126a6

Please sign in to comment.