Questions
Learn how to implement questions in a custom book.
Overview
How It Works
1
2
3
Usage
ask(concept_name: NounPhrasesStringLiteral, concept_type: Type[T], text: Optional[str] = None, choices: Optional[List[T]] = None) -> Union[T, Question[NounPhrasesStringLiteral, T]]Parameter
Required
Description
1
from kognitos.bdk.api.questions import ask, Question2
result = ask("project start date", str)result = ask("project start date", str, text="What is the start date of the project?")result = ask("project start date", str, choices=["2025-07-22", "2025-07-25", "2025-07-28"])3
if isinstance(result := ask("project start date", str), Question)
return result4
if isinstance(start_date := ask("project start date", str), Question):
return start_date
# Use the answer as a datetime object
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
project_due_date = date_obj + timedelta(days=30)5
@procedure("to get a project due (date)")
def get_due_date(self) -> str | Question[Literal["project start date"], str]:Examples
1. Asking a Question with Different Return Types
2. Asking Multiple Questions
How This Works
Last updated
Was this helpful?

