From 661dc59aec192467bc0c71472b240669c8447d64 Mon Sep 17 00:00:00 2001 From: Josh XT Date: Sun, 5 Jan 2025 15:06:51 -0500 Subject: [PATCH] add handling to endpoint --- agixt/endpoints/Prompt.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/agixt/endpoints/Prompt.py b/agixt/endpoints/Prompt.py index 4c7d30a52055..56a4ccfb8c5a 100644 --- a/agixt/endpoints/Prompt.py +++ b/agixt/endpoints/Prompt.py @@ -201,9 +201,12 @@ async def update_prompt( async def get_prompt_arg( prompt_name: str, prompt_category: str = "Default", user=Depends(verify_api_key) ): - prompt_name = prompt_name.replace("%20", " ") - prompt_category = prompt_category.replace("%20", " ") - prompt = Prompts(user=user).get_prompt( - prompt_name=prompt_name, prompt_category=prompt_category - ) - return {"prompt_args": Prompts(user=user).get_prompt_args(prompt)} + try: + prompt_name = prompt_name.replace("%20", " ") + prompt_category = prompt_category.replace("%20", " ") + prompt = Prompts(user=user).get_prompt( + prompt_name=prompt_name, prompt_category=prompt_category + ) + return {"prompt_args": Prompts(user=user).get_prompt_args(prompt)} + except Exception as e: + raise HTTPException(status_code=404, detail=f"Prompt not found.")