Make otp type also selectable in the totp endpoint (#4529)

This commit is contained in:
Shuchang Zheng
2026-01-23 00:39:07 -08:00
committed by GitHub
parent e361edce8f
commit 965ff7c0b8
4 changed files with 30 additions and 12 deletions

View File

@@ -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)