You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.5 KiB
Python
106 lines
2.5 KiB
Python
from typing import List, Dict, Any
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api.schemas import (
|
|
ChatRequest,
|
|
ChatResponse,
|
|
ConsultarEstoqueRequest,
|
|
ValidarClienteVendaRequest,
|
|
AvaliarVeiculoTrocaRequest,
|
|
AgendarRevisaoRequest,
|
|
CancelarPedidoRequest,
|
|
)
|
|
from app.db.database import SessionLocal
|
|
from app.services.orquestrador_service import OrquestradorService
|
|
from app.services.handlers import (
|
|
consultar_estoque,
|
|
validar_cliente_venda,
|
|
avaliar_veiculo_troca,
|
|
agendar_revisao,
|
|
cancelar_pedido,
|
|
)
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
'''
|
|
# Removido momentaniamente para teste do Vertex IA
|
|
@router.post("/chat", response_model=ChatResponse)
|
|
async def chat(request: ChatRequest, db: Session = Depends(get_db)):
|
|
service = OrquestradorService(db)
|
|
result = await service.handle_message(
|
|
message=request.message,
|
|
user_id=request.user_id,
|
|
)
|
|
return ChatResponse(response=result)
|
|
'''
|
|
@router.post("/chat", response_model=ChatResponse)
|
|
async def chat(request: ChatRequest, db: Session = Depends(get_db)):
|
|
service = OrquestradorService(db)
|
|
|
|
result = await service.handle_message(
|
|
message=request.message
|
|
)
|
|
|
|
return ChatResponse(response=result)
|
|
|
|
|
|
@router.post("/mock/consultar-estoque")
|
|
async def consultar_estoque_endpoint(
|
|
body: ConsultarEstoqueRequest,
|
|
) -> List[Dict[str, Any]]:
|
|
return await consultar_estoque(
|
|
preco_max=body.preco_max,
|
|
categoria=body.categoria,
|
|
)
|
|
|
|
|
|
@router.post("/mock/validar-cliente-venda")
|
|
async def validar_cliente_venda_endpoint(
|
|
body: ValidarClienteVendaRequest,
|
|
) -> Dict[str, Any]:
|
|
return await validar_cliente_venda(
|
|
cpf=body.cpf,
|
|
valor_veiculo=body.valor_veiculo,
|
|
)
|
|
|
|
|
|
@router.post("/mock/avaliar-veiculo-troca")
|
|
async def avaliar_veiculo_troca_endpoint(
|
|
body: AvaliarVeiculoTrocaRequest,
|
|
) -> Dict[str, Any]:
|
|
return await avaliar_veiculo_troca(
|
|
modelo=body.modelo,
|
|
ano=body.ano,
|
|
km=body.km,
|
|
)
|
|
|
|
|
|
@router.post("/mock/agendar-revisao")
|
|
async def agendar_revisao_endpoint(
|
|
body: AgendarRevisaoRequest,
|
|
) -> Dict[str, Any]:
|
|
return await agendar_revisao(
|
|
placa=body.placa,
|
|
data_hora=body.data_hora,
|
|
)
|
|
|
|
|
|
@router.post("/mock/cancelar-pedido")
|
|
async def cancelar_pedido_endpoint(
|
|
body: CancelarPedidoRequest,
|
|
) -> Dict[str, Any]:
|
|
return await cancelar_pedido(
|
|
numero_pedido=body.numero_pedido,
|
|
motivo=body.motivo,
|
|
)
|