class classify(BaseModel): check_docs: int web_search: int mentioned_company: str classify_llm = llm.as_structured_llm(output_cls=classify) fprompt = CLASSIFICATION.format( user_input="How can I contact your firm?") response = classify_llm.chat([ChatMessage( role="user", content=fprompt)]) print(response.raw.check_docs) print(response.raw.web_search) print(response.raw.mentioned_company)
ptemplate = PromptTemplate(CLASSIFICATION) response2 = llm.structured_predict( classify, ptemplate, user_input="How can I contact your firm?" )