38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from typing import Annotated
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
from typing import List
|
|
|
|
from pydantic import ValidationError
|
|
|
|
from enums import TypeMood, TypeModel
|
|
from genetic_algorithm.genetic_algorithm import genetic_algorithm, load_graph_from_request
|
|
from repository import QuestionRepository
|
|
from schemas import SQuestionAdd, SQuestion, SQuestionId, Flight, TripRequest
|
|
|
|
router = APIRouter(
|
|
prefix="/class",
|
|
tags=["Class"],
|
|
)
|
|
|
|
|
|
@router.post("/get_flight/")
|
|
async def get_flight(request: TripRequest):
|
|
graph, start_point, end_point, flights_data = load_graph_from_request(request)
|
|
result = genetic_algorithm(start_point, end_point, graph, flights_data)
|
|
if not result:
|
|
raise HTTPException(status_code=404, detail="No valid paths found")
|
|
return result
|
|
|
|
@router.get("/negative")
|
|
async def get_class_names() -> List[str]:
|
|
with open(".//neural_network/classification/class_names_negative.txt", "r", encoding="utf-8") as file:
|
|
class_names = [line.strip() for line in file.readlines()]
|
|
return class_names
|
|
|
|
@router.get("/positive")
|
|
async def get_class_names() -> List[str]:
|
|
with open(".//neural_network/classification/class_names_positive.txt", "r", encoding="utf-8") as file:
|
|
class_names = [line.strip() for line in file.readlines()]
|
|
return class_names
|
|
|