mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-08-09 03:06:05 +02:00
feat(add network.retry):
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
from agentic_security.config import CfgMixin
|
from agentic_security.config import get_or_create_config
|
||||||
from agentic_security.core.app import set_secrets
|
from agentic_security.core.app import set_secrets
|
||||||
|
|
||||||
|
|
||||||
class InMemorySecrets:
|
class InMemorySecrets:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.secrets = {}
|
config = get_or_create_config()
|
||||||
self.config = CfgMixin()
|
self.secrets = config.get_config_value("secrets", {})
|
||||||
self.config.get_or_create_config()
|
|
||||||
self.secrets = self.config.config.get("secrets", {})
|
|
||||||
set_secrets(self.secrets)
|
set_secrets(self.secrets)
|
||||||
|
|
||||||
def set_secret(self, key: str, value: str):
|
def set_secret(self, key: str, value: str):
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from enum import Enum
|
|||||||
import httpx
|
import httpx
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from agentic_security.config import settings_var
|
||||||
|
|
||||||
|
|
||||||
class Modality(Enum):
|
class Modality(Enum):
|
||||||
TEXT = 0
|
TEXT = 0
|
||||||
@@ -90,7 +92,9 @@ class LLMSpec(BaseModel):
|
|||||||
content = self.body.replace("<<PROMPT>>", escape_special_chars_for_json(prompt))
|
content = self.body.replace("<<PROMPT>>", escape_special_chars_for_json(prompt))
|
||||||
content = content.replace("<<BASE64_IMAGE>>", encoded_image)
|
content = content.replace("<<BASE64_IMAGE>>", encoded_image)
|
||||||
content = content.replace("<<BASE64_AUDIO>>", encoded_audio)
|
content = content.replace("<<BASE64_AUDIO>>", encoded_audio)
|
||||||
async with httpx.AsyncClient() as client:
|
|
||||||
|
transport = httpx.AsyncHTTPTransport(retries=settings_var("network.retry", 3))
|
||||||
|
async with httpx.AsyncClient(transport=transport) as client:
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
method=self.method,
|
method=self.method,
|
||||||
url=self.url,
|
url=self.url,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from rich.console import Console
|
|||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
|
|
||||||
from agentic_security.config import CfgMixin # Importing the configuration mixin
|
from agentic_security.config import SettingsMixin # Importing the configuration mixin
|
||||||
from agentic_security.models.schemas import Scan
|
from agentic_security.models.schemas import Scan
|
||||||
from agentic_security.probe_data import REGISTRY
|
from agentic_security.probe_data import REGISTRY
|
||||||
from agentic_security.routes.scan import streaming_response_generator
|
from agentic_security.routes.scan import streaming_response_generator
|
||||||
@@ -23,7 +23,7 @@ YELLOW = colorama.Fore.YELLOW
|
|||||||
BLUE = colorama.Fore.BLUE
|
BLUE = colorama.Fore.BLUE
|
||||||
|
|
||||||
|
|
||||||
class AgenticSecurity(CfgMixin):
|
class AgenticSecurity(SettingsMixin):
|
||||||
@classmethod
|
@classmethod
|
||||||
async def async_scan(
|
async def async_scan(
|
||||||
cls,
|
cls,
|
||||||
|
|||||||
Reference in New Issue
Block a user