curl --request POST \
--url https://api.example.com/qa/ask \
--header 'Content-Type: application/json' \
--data '
{
"question_lecture": "<string>",
"question_title": "<string>",
"question_body": "<string>"
}
'{
"answer": "<string>",
"confidence": 123,
"citations": [
{}
],
"latency_ms": 123,
"retrieval_accuracy": 123,
"hallucination_flag": true
}curl --request POST \
--url https://api.example.com/qa/ask \
--header 'Content-Type: application/json' \
--data '
{
"question_lecture": "<string>",
"question_title": "<string>",
"question_body": "<string>"
}
'{
"answer": "<string>",
"confidence": 123,
"citations": [
{}
],
"latency_ms": 123,
"retrieval_accuracy": 123,
"hallucination_flag": true
}Documentation Index
Fetch the complete documentation index at: https://mintlify.com/RaviTejaMedarametla/Data-Science-AI-Portfolio/llms.txt
Use this file to discover all available pages before exploring further.
POST /qa/ask
POST /qa (also available at this path)
min_length=1Example: “Calculations and Aggregations”min_length=1Example: “Why use SUM in GM% calculation?”min_length=1Example: “I don’t understand why we need to wrap the calculation in SUM() when calculating gross margin percentage. Can you explain?”[Section: <section>, Lecture: <lecture>]Empty array if no citations provided.true if citations exist but retrieval_accuracy < 1.0.curl -X POST "http://localhost:8001/qa/ask" \
-H "Content-Type: application/json" \
-H "accept: application/json" \
-d '{
"question_lecture": "Calculations and Aggregations",
"question_title": "Why use SUM in GM% calculation?",
"question_body": "I do not understand why we need to wrap the calculation in SUM() when calculating gross margin percentage. Can you explain when and why we use SUM in calculated fields?"
}'
{
"answer": "When calculating gross margin percentage (GM%) in Tableau, you need to use SUM() because you're working with aggregated data. The formula GM% = (Revenue - COGS) / Revenue needs to aggregate individual transaction values before performing the division.\n\nIf you don't use SUM(), Tableau will try to calculate the percentage at the row level before aggregation, which gives incorrect results. The SUM() function ensures that all revenue and COGS values are totaled first, then the percentage is calculated on those totals.\n\nFor example:\n- Correct: SUM([Revenue] - [COGS]) / SUM([Revenue])\n- Incorrect: ([Revenue] - [COGS]) / [Revenue]\n\nThis is a common pattern for all ratio and percentage calculations in Tableau when working with transactional data.\n\nCitations:\n- [Section: Calculations, Lecture: Adding a custom calculation]\n- [Section: Aggregations, Lecture: Understanding SUM and AVG]",
"confidence": 0.8752,
"citations": [
"[Section: Calculations, Lecture: Adding a custom calculation]",
"[Section: Aggregations, Lecture: Understanding SUM and AVG]"
],
"latency_ms": 1847.3421,
"retrieval_accuracy": 1.0,
"hallucination_flag": false
}
{
"answer": "I don't have enough context to answer confidently.",
"confidence": 0.05,
"citations": [],
"latency_ms": 234.1245,
"retrieval_accuracy": 0.0,
"hallucination_flag": false
}
{
"answer": "You should use SUM() for aggregating measures...\n\nCitations:\n- [Section: Advanced Features, Lecture: Data Modeling]",
"confidence": 0.5834,
"citations": [
"[Section: Advanced Features, Lecture: Data Modeling]"
],
"latency_ms": 1923.8456,
"retrieval_accuracy": 0.0,
"hallucination_flag": true
}
src/qa_api.py:222-279
Request Model: QARequest (src/qa_api.py:32-35)
class QARequest(BaseModel):
question_lecture: str = Field(..., min_length=1)
question_title: str = Field(..., min_length=1)
question_body: str = Field(..., min_length=1)
QAResponse (src/qa_api.py:38-44)
class QAResponse(BaseModel):
answer: str
confidence: float
citations: List[str]
latency_ms: float
retrieval_accuracy: float
hallucination_flag: bool
question = f"Lecture: {req.question_lecture}\nTitle: {req.question_title}\nBody: {req.question_body}"
[1] Section: Calculations | Lecture: Adding a custom calculation
<document content>
[2] Section: Aggregations | Lecture: Understanding SUM and AVG
<document content>
[Section: X, Lecture: Y]r"\[Section:\s*.*?,\s*Lecture:\s*.*?\]"
valid_citations = sum(1 for c in citations if c in allowed_citations)
accuracy = valid_citations / len(citations)
coverage = min(len(retrieved_docs) / 4.0, 1.0) # 40%
nonempty = 1.0 if len(answer) > 20 else 0.0 # 20%
confidence = 0.4 * coverage + 0.4 * retrieval_accuracy + 0.2 * nonempty
hallucination_flag = bool(citations) and retrieval_accuracy < 1.0
monitoring["requests_total"] += 1
monitoring["latency_ms_total"] += latency_ms
monitoring["retrieval_accuracy_total"] += retrieval_accuracy
if hallucination_flag:
monitoring["hallucination_count"] += 1
GET /monitoring endpoint.
src/qa_api.py:78-88:
You are a helpful teaching assistant for a Tableau course.
You will receive a student question and supporting context passages.
Rules:
1) Answer ONLY using the supplied context.
2) If context is insufficient, say exactly: "I don't have enough context to answer confidently."
3) Add a short "Citations" section at the end.
4) Each citation must use this format:
- [Section: <section>, Lecture: <lecture>]
5) Do not invent citations.