<commit_before>import json

import fastapi

from app.models import RecommendRoutesForm
from app.services import route_recommendation_service

router = fastapi.APIRouter()


@router.post("/api/recommend_routes", description="generated recommended routes for given material")
def recommend_routes(form: RecommendRoutesForm):
    return fastapi.responses.JSONResponse(
        content=json.loads(route_recommendation_service(form).to_json()),
        status_code=201
    )<commit_msg>more efficiently create the json response<commit_after>import fastapi

from app.models import RecommendRoutesForm
from app.services import route_recommendation_service

router = fastapi.APIRouter()


@router.post("/api/recommend_routes", description="generated recommended routes for given material")
def recommend_routes(form: RecommendRoutesForm):
    return fastapi.responses.Response(
        content=route_recommendation_service(form).to_json(),
        status_code=201,
        media_type='application/json',
    )
{'fraction_non_alphanumeric': 0.08291708291708291, 'fraction_numerical': 0.005994005994005994, 'mean_word_length': 5.77027027027027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1270504', 'n_tokens_mistral': 288, 'n_tokens_neox': 271, 'n_words': 60}