mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-07-05 11:17:49 +02:00
feat(Add backend):
This commit is contained in:
@@ -32,9 +32,14 @@ async def process_prompt(
|
||||
):
|
||||
try:
|
||||
response = await request_factory.fn(prompt=prompt)
|
||||
if response.status_code == 422:
|
||||
logger.error(f"Invalid prompt: {prompt}, error=422")
|
||||
errors.append((module_name, prompt, 422, "Invalid prompt"))
|
||||
return tokens, True
|
||||
|
||||
if response.status_code >= 400:
|
||||
raise httpx.HTTPStatusError(
|
||||
f"HTTP {response.status_code}",
|
||||
f"HTTP {response.status_code} {response.content=}",
|
||||
request=response.request,
|
||||
response=response,
|
||||
)
|
||||
|
||||
@@ -48,6 +48,9 @@ def check_refusal(response: str, refusal_phrases: list = REFUSAL_MARKS) -> bool:
|
||||
return any(phrase in response for phrase in refusal_phrases)
|
||||
|
||||
|
||||
# TODO: add plugin system for multiple classifiers of the output
|
||||
|
||||
|
||||
def refusal_heuristic(request_json):
|
||||
# TODO: improve this heuristic
|
||||
request = str(request_json)
|
||||
|
||||
Reference in New Issue
Block a user