refactor: фаза 5 — чистка (APP_VERSION, LLM константы)
- constants.py: APP_VERSION, LLM_DEFAULT_TEMPERATURE, LLM_RESPONSE_FORMAT - main.py: версия из APP_VERSION (вместо хардкод '0.1.0'×2) - llm.py: temperature и response_format из constants Всего: 85 тестов, ruff clean
This commit is contained in:
@@ -154,6 +154,8 @@ CSV_MEDIA_TYPE = "text/csv"
|
||||
LLM_DEFAULT_MODEL = "gpt-4o-mini"
|
||||
LLM_DEFAULT_API_BASE = "https://api.openai.com/v1"
|
||||
LLM_DEFAULT_TIMEOUT = 30
|
||||
LLM_DEFAULT_TEMPERATURE = 0.3
|
||||
LLM_RESPONSE_FORMAT = "json_object"
|
||||
LLM_ANALYSIS_SYSTEM_PROMPT = (
|
||||
"You are a security analyst reviewing GuardDog findings for a software package. "
|
||||
"Given a finding (rule name, severity, message, code snippet, location), "
|
||||
@@ -173,6 +175,7 @@ LLM_ANALYSIS_SYSTEM_PROMPT = (
|
||||
APP_NAME = "GuardDog Nexus"
|
||||
APP_DESCRIPTION = "Scan PyPI packages from Sonatype Nexus webhooks using GuardDog"
|
||||
APP_PACKAGE = "guarddog_nexus"
|
||||
APP_VERSION = "0.1.0"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# HTTP
|
||||
|
||||
@@ -9,7 +9,7 @@ import json
|
||||
import httpx
|
||||
|
||||
from ..config import config
|
||||
from ..constants import LLM_ANALYSIS_SYSTEM_PROMPT
|
||||
from ..constants import LLM_ANALYSIS_SYSTEM_PROMPT, LLM_DEFAULT_TEMPERATURE, LLM_RESPONSE_FORMAT
|
||||
from ..logging_setup import log
|
||||
|
||||
_llm_semaphore = asyncio.Semaphore(config.llm_max_concurrent)
|
||||
@@ -60,8 +60,8 @@ async def analyze_finding(finding_data: dict) -> dict | None:
|
||||
{"role": "system", "content": LLM_ANALYSIS_SYSTEM_PROMPT},
|
||||
{"role": "user", "content": _build_user_message(finding_data)},
|
||||
],
|
||||
"temperature": 0.3,
|
||||
"response_format": {"type": "json_object"},
|
||||
"temperature": LLM_DEFAULT_TEMPERATURE,
|
||||
"response_format": {"type": LLM_RESPONSE_FORMAT},
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@@ -9,7 +9,13 @@ from fastapi.staticfiles import StaticFiles
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
|
||||
from guarddog_nexus.config import config
|
||||
from guarddog_nexus.constants import APP_DESCRIPTION, APP_NAME, APP_PACKAGE, STATIC_MOUNT_PATH
|
||||
from guarddog_nexus.constants import (
|
||||
APP_DESCRIPTION,
|
||||
APP_NAME,
|
||||
APP_PACKAGE,
|
||||
APP_VERSION,
|
||||
STATIC_MOUNT_PATH,
|
||||
)
|
||||
from guarddog_nexus.db.engine import init_db
|
||||
from guarddog_nexus.i18n import DEFAULT_LANG, LANGUAGES
|
||||
from guarddog_nexus.logging_setup import log
|
||||
@@ -52,7 +58,7 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
app = FastAPI(
|
||||
title=APP_NAME,
|
||||
version="0.1.0",
|
||||
version=APP_VERSION,
|
||||
description=APP_DESCRIPTION,
|
||||
lifespan=lifespan,
|
||||
)
|
||||
@@ -71,7 +77,7 @@ if os.path.isdir(STATIC_DIR):
|
||||
|
||||
@app.get("/health")
|
||||
async def health():
|
||||
return {"status": "ok", "version": "0.1.0"}
|
||||
return {"status": "ok", "version": APP_VERSION}
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user