Skip to content

Commit

Permalink
Merge pull request #2342 from Agenta-AI/fix/no-status-code-passthrough
Browse files Browse the repository at this point in the history
[Fix] Errors in llm apps freezes the playground
  • Loading branch information
jp-agenta authored Dec 6, 2024
2 parents e11f848 + 9d856ca commit 73335ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion agenta-cli/agenta/sdk/decorators/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def handle_failure(self, error: Exception):
log.warning(format_exc().strip("\n"))
log.warning("--------------------------------------------------")

status_code = error.status_code if hasattr(error, "status_code") else 500
status_code = 500
message = str(error)
stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore
detail = {"message": message, "stacktrace": stacktrace}
Expand Down
20 changes: 16 additions & 4 deletions agenta-web/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export async function callVariant(
return response
})
.catch(async (error) => {
console.log("Unsecure call to LLM App failed:", error?.status)
console.log("Unsecure call to LLM App failed:", error)

if (error?.response?.status !== 401) {
throw error
}

let response = await axios
.post(secure_url, requestBody, {
Expand All @@ -163,7 +167,9 @@ export async function callVariant(
return response
})
.catch((error) => {
console.log("Secure call to LLM App failed:", error?.status)
console.log("Secure call to LLM App failed:", error)

throw error
})

return response
Expand Down Expand Up @@ -200,7 +206,11 @@ export const fetchVariantParametersFromOpenAPI = async (
return response
})
.catch(async (error) => {
console.log("Unsecure call to LLM App failed:", error?.status)
console.log("Unsecure call to LLM App failed:", error)

if (error?.response?.status !== 401) {
throw error
}

let response = await axios
.get(secure_url, {
Expand All @@ -211,7 +221,9 @@ export const fetchVariantParametersFromOpenAPI = async (
return response
})
.catch((error) => {
console.log("Secure call to LLM App failed:", error?.status)
console.log("Secure call to LLM App failed:", error)

throw error
})

return response
Expand Down

0 comments on commit 73335ee

Please sign in to comment.