Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 3,078 Bytes
70f23d5 fad5e6f 70f23d5 36c0ef0 70f23d5 6a42f82 70f23d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
from typing import List, Optional, Literal
from pydantic import BaseModel, Field
from sanatan_assistant import allowedScriptureTitles
class Question(BaseModel):
preferred_language: str = Field(
description="User's preferred language. Respond in this language"
)
question: str = Field(description="The generated question to be asked to the user. Do not capture the expected answer here. Just the question only.")
scripture: allowedScriptureTitles = Field(
description="The scripture title this question is sourced from (e.g., Bhagavad Gita, Divya Prabandham)"
)
native_lyrics: str = Field(
description="The lyrics in its native/original script (e.g., Sanskrit/Tamil). Sanitize this if there are garbled characters. This could be multi-line. capture entirely."
)
transliteration: str = Field(
description="The transliterated text of the verse in English/the user's preferred language"
)
translation: str = Field(
description="The translated meaning of the verse in English/the user's preferred language"
)
detailed_explanation: Optional[str] = Field(
default=None,
description="A detailed explanation of the verse or context, if available in the context",
)
word_by_word_meaning: Optional[str] = Field(
default=None,
description="Word-by-word meaning (in both native and english) or breakdown of the verse, if available in the context",
)
verse_number: Optional[int] = Field(
default=None,
description="The absolute verse number from the context if available.",
)
page_number: Optional[int] = Field(
default=None, description="The page number from the context if available."
)
verse_reference: Optional[str] = Field(
default=None,
description="The reference identifier of the verse or the title (e.g., TVM 1.4.5). Include the prabandham_name as well if available. Do not capture the scripture name here.",
)
reference_link: Optional[str] = Field(
default=None, description="The html_url if available"
)
complexity: Literal["beginner", "intermediate", "advanced"] = Field(
description="Difficulty level of the question"
)
choices: List[str] = Field(
description="List of multiple-choice options. Leave empty for open-text questions"
)
expected_answer: str = Field(
description="The correct or expected answer to the question"
)
answer_explanation: str = Field(
description="Explanation why the expected answer is correct"
)
expected_choice_index: Optional[int] = Field(
default=None,
description="Index of the correct choice in 'choices'. Null if open-text question",
)
class AnswerValidation(BaseModel):
is_correct: bool = Field(description="Whether the provided answer is correct")
reasoning: str = Field(description="Explanation of why the answer is correct or not")
correct_answer: str = Field(description="The correct/expected answer from the question object")
|