refactor: remove unused GET /prompts/command/{command} endpoint (#24782)
The lookup-prompt-by-command endpoint's only frontend wrapper, getPromptByCommand, is dead: nothing imports or calls it, the path is referenced nowhere else, and the route handler has no internal caller (slash-command resolution happens client-side from the loaded prompt list). Removes the route handler, its section header, and the dead wrapper. The shared Prompts.get_prompt_by_command data-layer method is kept: it is still used by create/update prompt validation (prompts.py:175, 275, 340). PromptAccessResponse and AccessGrants are untouched. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c8f851bd2d
commit
b9911c8bc6
2 files changed
-78
No files matched your search
@@ -188,50 +188,6 @@ async def create_new_prompt(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
############################
|
|
||||||
# GetPromptByCommand
|
|
||||||
############################
|
|
||||||
|
|
||||||
|
|
||||||
@router.get('/command/{command}', response_model=PromptAccessResponse | None)
|
|
||||||
async def get_prompt_by_command(
|
|
||||||
command: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)
|
|
||||||
):
|
|
||||||
prompt = await Prompts.get_prompt_by_command(command, db=db)
|
|
||||||
|
|
||||||
if prompt:
|
|
||||||
if (
|
|
||||||
user.role == 'admin'
|
|
||||||
or prompt.user_id == user.id
|
|
||||||
or await AccessGrants.has_access(
|
|
||||||
user_id=user.id,
|
|
||||||
resource_type='prompt',
|
|
||||||
resource_id=prompt.id,
|
|
||||||
permission='read',
|
|
||||||
db=db,
|
|
||||||
)
|
|
||||||
):
|
|
||||||
return PromptAccessResponse(
|
|
||||||
**prompt.model_dump(),
|
|
||||||
write_access=(
|
|
||||||
(user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL)
|
|
||||||
or user.id == prompt.user_id
|
|
||||||
or await AccessGrants.has_access(
|
|
||||||
user_id=user.id,
|
|
||||||
resource_type='prompt',
|
|
||||||
resource_id=prompt.id,
|
|
||||||
permission='write',
|
|
||||||
db=db,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
|
||||||
detail=ERROR_MESSAGES.NOT_FOUND,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# GetPromptById
|
# GetPromptById
|
||||||
############################
|
############################
|
||||||
|
|||||||
@@ -226,40 +226,6 @@ export const getPromptList = async (token: string = '') => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPromptByCommand = async (token: string, command: string) => {
|
|
||||||
let error = null;
|
|
||||||
|
|
||||||
command = command.charAt(0) === '/' ? command.slice(1) : command;
|
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/command/${command}`, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
Accept: 'application/json',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
authorization: `Bearer ${token}`
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.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 getPromptById = async (token: string, promptId: string) => {
|
export const getPromptById = async (token: string, promptId: string) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user