Skip to content

Instantly share code, notes, and snippets.

@jcabot
Created March 23, 2022 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcabot/b0d5b3963c395251d998dff364398efb to your computer and use it in GitHub Desktop.
Save jcabot/b0d5b3963c395251d998dff364398efb to your computer and use it in GitHub Desktop.
Wrapping of the intent classifier in a REST Api
@app.post("/bot/{name}/train/")
def bot_train(name: str, configurationdto: ConfigurationDTO):
if name not in bots.keys():
raise HTTPException(status_code=422, detail="Bot does not exist")
bot: Bot = bots[name]
if len(bot.contexts) == 0:
raise HTTPException(status_code=422, detail="Bot is empty, nothing to train")
bot.configuration = configurationdto_to_configuration(configurationdto)
train(bot)
return {"status:" : "successful training for " + str(len(bot.contexts)) + " contexts"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment