Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

77
Vistas
How to use the input through get request as a variable in fastapi

I am using fast API to do predictions. I am taking the if and the inputs through the get request and returning the response. But I want to change the endpoint dynamically from the input id given by the user and I was unable to do it. I am getting name task_id is not defined

from pydantic import BaseModel
class SoluteSolvent(BaseModel):
    solvent: str
    solute: str
    task_id: int

api_names = ['/predict','/predict_json']

@app.get(api_names[task_id])
def predict(task_id: int,solute: str, solvent: str):
    if task_id == 0:
        results = predictions(solute, solvent)
        response["interaction_map"] = (results[1].detach().numpy()).tolist()
        response["predictions"] = results[0].item()
        return {'result': response}
    elif task_id == 1:
        return "this is second one"
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda