Make otp type also selectable in the totp endpoint (#4529)
This commit is contained in:
@@ -36,12 +36,20 @@ class OTPResultParsedByLLM(BaseModel):
|
||||
otp_value: str | None = Field(None, description="The OTP value.")
|
||||
|
||||
|
||||
async def parse_otp_login(content: str, organization_id: str) -> OTPValue | None:
|
||||
prompt = prompt_engine.load_prompt("parse-otp-login", content=content)
|
||||
async def parse_otp_login(
|
||||
content: str,
|
||||
organization_id: str,
|
||||
enforced_otp_type: OTPType | None = None,
|
||||
) -> OTPValue | None:
|
||||
prompt = prompt_engine.load_prompt(
|
||||
"parse-otp-login",
|
||||
content=content,
|
||||
enforced_otp_type=enforced_otp_type.value if enforced_otp_type else None,
|
||||
)
|
||||
resp = await app.SECONDARY_LLM_API_HANDLER(
|
||||
prompt=prompt, prompt_name="parse-otp-login", organization_id=organization_id
|
||||
)
|
||||
LOG.info("OTP Login Parser Response", resp=resp)
|
||||
LOG.info("OTP Login Parser Response", resp=resp, enforced_otp_type=enforced_otp_type)
|
||||
otp_result = OTPResultParsedByLLM.model_validate(resp)
|
||||
if otp_result.otp_value_found and otp_result.otp_value:
|
||||
return OTPValue(value=otp_result.otp_value, type=otp_result.otp_type)
|
||||
|
||||
Reference in New Issue
Block a user