refactor: Update API endpoints to include 'loras' prefix for consistency

This commit is contained in:
Will Miao
2025-07-24 19:56:18 +08:00
parent f15c6f33f9
commit 692796db46
10 changed files with 21 additions and 21 deletions

View File

@@ -45,21 +45,21 @@ class LoraRoutes(BaseModelRoutes):
app.router.add_get(f'/api/{prefix}/letter-counts', self.get_letter_counts) app.router.add_get(f'/api/{prefix}/letter-counts', self.get_letter_counts)
app.router.add_get(f'/api/{prefix}/get-notes', self.get_lora_notes) app.router.add_get(f'/api/{prefix}/get-notes', self.get_lora_notes)
app.router.add_get(f'/api/{prefix}/get-trigger-words', self.get_lora_trigger_words) app.router.add_get(f'/api/{prefix}/get-trigger-words', self.get_lora_trigger_words)
app.router.add_get(f'/api/lora-preview-url', self.get_lora_preview_url) app.router.add_get(f'/api/{prefix}/preview-url', self.get_lora_preview_url)
app.router.add_get(f'/api/lora-civitai-url', self.get_lora_civitai_url) app.router.add_get(f'/api/{prefix}/civitai-url', self.get_lora_civitai_url)
app.router.add_get(f'/api/lora-model-description', self.get_lora_model_description) app.router.add_get(f'/api/{prefix}/model-description', self.get_lora_model_description)
# LoRA-specific management routes # LoRA-specific management routes
app.router.add_post(f'/api/move_model', self.move_model) app.router.add_post(f'/api/{prefix}/move_model', self.move_model)
app.router.add_post(f'/api/move_models_bulk', self.move_models_bulk) app.router.add_post(f'/api/{prefix}/move_models_bulk', self.move_models_bulk)
# CivitAI integration with LoRA-specific validation # CivitAI integration with LoRA-specific validation
app.router.add_get(f'/api/{prefix}/civitai/versions/{{model_id}}', self.get_civitai_versions_lora) app.router.add_get(f'/api/{prefix}/civitai/versions/{{model_id}}', self.get_civitai_versions_lora)
app.router.add_get(f'/api/civitai/model/version/{{modelVersionId}}', self.get_civitai_model_by_version) app.router.add_get(f'/api/{prefix}/civitai/model/version/{{modelVersionId}}', self.get_civitai_model_by_version)
app.router.add_get(f'/api/civitai/model/hash/{{hash}}', self.get_civitai_model_by_hash) app.router.add_get(f'/api/{prefix}/civitai/model/hash/{{hash}}', self.get_civitai_model_by_hash)
# ComfyUI integration # ComfyUI integration
app.router.add_post(f'/loramanager/get_trigger_words', self.get_trigger_words) app.router.add_post(f'/api/{prefix}/get_trigger_words', self.get_trigger_words)
def _parse_specific_params(self, request: web.Request) -> Dict: def _parse_specific_params(self, request: web.Request) -> Dict:
"""Parse LoRA-specific parameters""" """Parse LoRA-specific parameters"""

View File

@@ -125,7 +125,7 @@ export async function refreshSingleLoraMetadata(filePath) {
export async function fetchModelDescription(modelId, filePath) { export async function fetchModelDescription(modelId, filePath) {
try { try {
const response = await fetch(`/api/lora-model-description?model_id=${modelId}&file_path=${encodeURIComponent(filePath)}`); const response = await fetch(`/api/loras/model-description?model_id=${modelId}&file_path=${encodeURIComponent(filePath)}`);
if (!response.ok) { if (!response.ok) {
throw new Error(`Failed to fetch model description: ${response.statusText}`); throw new Error(`Failed to fetch model description: ${response.statusText}`);

View File

@@ -209,9 +209,9 @@ export class RecipeContextMenu extends BaseContextMenu {
// Determine which endpoint to use based on available data // Determine which endpoint to use based on available data
if (lora.modelVersionId) { if (lora.modelVersionId) {
endpoint = `/api/civitai/model/version/${lora.modelVersionId}`; endpoint = `/api/loras/civitai/model/version/${lora.modelVersionId}`;
} else if (lora.hash) { } else if (lora.hash) {
endpoint = `/api/civitai/model/hash/${lora.hash}`; endpoint = `/api/loras/civitai/model/hash/${lora.hash}`;
} else { } else {
console.error("Missing both hash and modelVersionId for lora:", lora); console.error("Missing both hash and modelVersionId for lora:", lora);
return null; return null;

View File

@@ -831,9 +831,9 @@ class RecipeModal {
// Determine which endpoint to use based on available data // Determine which endpoint to use based on available data
if (lora.modelVersionId) { if (lora.modelVersionId) {
endpoint = `/api/civitai/model/version/${lora.modelVersionId}`; endpoint = `/api/loras/civitai/model/version/${lora.modelVersionId}`;
} else if (lora.hash) { } else if (lora.hash) {
endpoint = `/api/civitai/model/hash/${lora.hash}`; endpoint = `/api/loras/civitai/model/hash/${lora.hash}`;
} else { } else {
console.error("Missing both hash and modelVersionId for lora:", lora); console.error("Missing both hash and modelVersionId for lora:", lora);
return null; return null;

View File

@@ -59,7 +59,7 @@ export async function loadModelDescription(modelId, filePath) {
descriptionContainer.classList.add('hidden'); descriptionContainer.classList.add('hidden');
// Determine API endpoint based on file path or context // Determine API endpoint based on file path or context
let apiEndpoint = `/api/lora-model-description?model_id=${modelId}&file_path=${encodeURIComponent(filePath)}`; let apiEndpoint = `/api/loras/model-description?model_id=${modelId}&file_path=${encodeURIComponent(filePath)}`;
// Try to get model description from API // Try to get model description from API
const response = await fetch(apiEndpoint); const response = await fetch(apiEndpoint);

View File

@@ -219,7 +219,7 @@ class MoveManager {
return; return;
} }
const response = await fetch('/api/move_model', { const response = await fetch('/api/loras/move_model', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -257,7 +257,7 @@ class MoveManager {
return; return;
} }
const response = await fetch('/api/move_models_bulk', { const response = await fetch('/api/loras/move_models_bulk', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

View File

@@ -147,7 +147,7 @@ export function addLorasWidget(node, name, opts, callback) {
this.currentLora = loraName; this.currentLora = loraName;
// 获取预览URL // 获取预览URL
const response = await api.fetchApi(`/lora-preview-url?name=${encodeURIComponent(loraName)}`, { const response = await api.fetchApi(`/loras/preview-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET' method: 'GET'
}); });
@@ -472,7 +472,7 @@ export function addLorasWidget(node, name, opts, callback) {
try { try {
// Get Civitai URL from API // Get Civitai URL from API
const response = await api.fetchApi(`/lora-civitai-url?name=${encodeURIComponent(loraName)}`, { const response = await api.fetchApi(`/loras/civitai-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET' method: 'GET'
}); });

View File

@@ -165,7 +165,7 @@ export class PreviewTooltip {
this.currentLora = loraName; this.currentLora = loraName;
// Get preview URL // Get preview URL
const response = await api.fetchApi(`/lora-preview-url?name=${encodeURIComponent(loraName)}`, { const response = await api.fetchApi(`/loras/preview-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET' method: 'GET'
}); });

View File

@@ -265,7 +265,7 @@ export function createContextMenu(x, y, loraName, widget, previewTooltip, render
try { try {
// Get Civitai URL from API // Get Civitai URL from API
const response = await api.fetchApi(`/lora-civitai-url?name=${encodeURIComponent(loraName)}`, { const response = await api.fetchApi(`/loras/civitai-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET' method: 'GET'
}); });

View File

@@ -174,7 +174,7 @@ export function collectActiveLorasFromChain(node, visited = new Set()) {
export function updateConnectedTriggerWords(node, loraNames) { export function updateConnectedTriggerWords(node, loraNames) {
const connectedNodeIds = getConnectedTriggerToggleNodes(node); const connectedNodeIds = getConnectedTriggerToggleNodes(node);
if (connectedNodeIds.length > 0) { if (connectedNodeIds.length > 0) {
fetch("/loramanager/get_trigger_words", { fetch("/api/loras/get_trigger_words", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({