Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions backend/app/api/routes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
}
from app.core.exceptions import CorkedError, EmptyCellarError
from app.database.repositories.evaluation import EvaluationRepository
from app.graph.graph_factory import EvaluationMode
from app.models.graph import (
ReactFlowGraph,
TraceEvent,
ModeResponse,
EvaluationMode,
Graph3DPayload,
)
from app.services.graph_builder import (
build_six_hats_topology,
build_six_sommeliers_topology,
build_full_techniques_topology,
)
from app.services.graph_builder_3d import build_3d_graph
Expand Down Expand Up @@ -66,11 +66,11 @@ def _check_ownership(evaluation: dict[str, Any], user, evaluation_id: str) -> No
# Allow access to public demo evaluations without auth
if evaluation_id in PUBLIC_DEMO_EVALUATIONS:
return

# Require auth for non-public evaluations
if user is None:
raise CorkedError("Authentication required to view this evaluation")

if evaluation.get("user_id") != user.id:
raise CorkedError(
"Access denied: evaluation belongs to another user", status_code=403
Expand All @@ -84,14 +84,16 @@ def _determine_mode(evaluation: dict[str, Any]) -> EvaluationMode:
evaluation: The evaluation document.

Returns:
EvaluationMode (six_hats or full_techniques).
EvaluationMode (six_sommeliers, grand_tasting, or full_techniques).
"""
# Check for explicit mode in evaluation data
mode = evaluation.get("mode")
# Check for explicit evaluation_mode first, then fall back to mode
mode = evaluation.get("evaluation_mode") or evaluation.get("mode")
if mode == EvaluationMode.FULL_TECHNIQUES.value:
return EvaluationMode.FULL_TECHNIQUES
# Default to six_hats mode
return EvaluationMode.SIX_HATS
if mode == EvaluationMode.GRAND_TASTING.value:
return EvaluationMode.GRAND_TASTING
# Default to six_sommeliers mode
return EvaluationMode.SIX_SOMMELIERS


@router.get("/{evaluation_id}/graph", response_model=ReactFlowGraph)
Expand Down Expand Up @@ -132,8 +134,8 @@ async def get_graph(

if mode == EvaluationMode.FULL_TECHNIQUES:
graph = build_full_techniques_topology()
else:
graph = build_six_hats_topology()
else: # SIX_SOMMELIERS, GRAND_TASTING
graph = build_six_sommeliers_topology()

logger.info(f"[Graph] Returning {mode.value} graph for {evaluation_id}")
return graph
Expand All @@ -159,8 +161,8 @@ async def get_graph_structure(
mode = _determine_mode(evaluation)
if mode == EvaluationMode.FULL_TECHNIQUES:
graph = build_full_techniques_topology()
else:
graph = build_six_hats_topology()
else: # SIX_SOMMELIERS, GRAND_TASTING
graph = build_six_sommeliers_topology()

return graph

Expand All @@ -185,8 +187,8 @@ async def get_graph_execution(
mode = _determine_mode(evaluation)
if mode == EvaluationMode.FULL_TECHNIQUES:
graph = build_full_techniques_topology()
else:
graph = build_six_hats_topology()
else: # SIX_SOMMELIERS, GRAND_TASTING
graph = build_six_sommeliers_topology()

methodology_trace = evaluation.get("methodology_trace", [])
if methodology_trace:
Expand Down Expand Up @@ -268,7 +270,7 @@ async def get_mode(
) -> ModeResponse:
"""Get current evaluation mode.

Returns the evaluation mode (six_hats or full_techniques)
Returns the evaluation mode (six_sommeliers, grand_tasting, or full_techniques)
for the specified evaluation.

Public demo evaluations can be accessed without authentication.
Expand Down
14 changes: 8 additions & 6 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Application settings and configuration"""

import secrets
from pydantic_settings import BaseSettings
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import List


Expand All @@ -15,6 +15,12 @@ class Settings(BaseSettings):
The default random value is only for development convenience.
"""

model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
)

APP_NAME: str = "Somm.dev API"
API_V1_STR: str = "/api"

Expand All @@ -38,6 +44,7 @@ class Settings(BaseSettings):

# LLM APIs
GEMINI_API_KEY: str = ""
OPENAI_API_KEY: str = ""

# Vertex AI Express (API key auth)
VERTEX_API_KEY: str = ""
Expand Down Expand Up @@ -79,10 +86,5 @@ def CORS_ORIGINS(self) -> List[str]:
origins.append(self.FRONTEND_URL.replace("https://www.", "https://", 1))
return origins

class Config:
env_file = ".env"
env_file_encoding = "utf-8"
case_sensitive = True


settings = Settings()
4 changes: 2 additions & 2 deletions backend/app/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class CorkedError(HTTPException):
analogous to a spoiled or invalid request.
"""

default_status_code = status.HTTP_400_BAD_REQUEST
status_code = status.HTTP_400_BAD_REQUEST
default_detail = "Invalid request data - the request is corked"

def __init__(self, detail: str = None, status_code: int = None):
super().__init__(
status_code=status_code or self.default_status_code,
status_code=status_code or self.__class__.status_code,
detail=detail or self.default_detail,
)

Expand Down
4 changes: 2 additions & 2 deletions backend/app/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
import sys
from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path


Expand All @@ -21,7 +21,7 @@ def setup_logging() -> logging.Logger:
log_dir = Path(__file__).parent.parent.parent / "logs"
log_dir.mkdir(exist_ok=True)

log_filename = log_dir / f"somm_{datetime.utcnow().strftime('%Y%m%d')}.log"
log_filename = log_dir / f"somm_{datetime.now(timezone.utc).strftime('%Y%m%d')}.log"

logger = logging.getLogger("somm")
logger.setLevel(logging.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions backend/app/criteria/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Evaluation criteria module for BMAD 17-item scoring system."""
Loading
Loading