{"openapi":"3.1.0","info":{"title":"FastAPI Backend","version":"1.0.0"},"paths":{"/api/extract-narratives":{"post":{"tags":["extraction"],"summary":"Extract Narratives","description":"Extract narrative questions from uploaded XLSX or DOCX template.\n\nArgs:\n    file: Template file (.xlsx or .docx)\n    sheets: Optional JSON array of sheet names to process (XLSX only)\n            Example: '[\"Sheet1\", \"Sheet2\"]'\n\nReturns:\n    Extracted narrative questions with source locations\n\nRaises:\n    400: Unsupported file type or invalid sheets parameter\n    413: File too large\n    422: File parsing error\n    500: LLM API error or missing configuration","operationId":"extract_narratives_api_extract_narratives_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_extract_narratives_api_extract_narratives_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/generate-narrative-answer":{"post":{"tags":["generation"],"summary":"Generate Answer Endpoint","description":"Generate a narrative answer using AI.\n\nArgs:\n    request: GenerateAnswerRequest with question, context, and options\n\nReturns:\n    GenerateAnswerResponse with generated answer and metadata\n\nRaises:\n    HTTPException: 400 for validation errors, 500 for generation failures","operationId":"generate_answer_endpoint_api_generate_narrative_answer_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateAnswerRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateAnswerResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/identify-form-question":{"post":{"tags":["generation"],"summary":"Identify Form Question Endpoint","description":"Given a list of form questions, identify which one's answer would best\nuniquely identify a respondent. Returns the question ID or null if none\nis suitable.","operationId":"identify_form_question_endpoint_api_identify_form_question_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentifyQuestionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentifyQuestionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/":{"get":{"summary":"Root","description":"Root endpoint.","operationId":"root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/health":{"get":{"summary":"Health Check","description":"Health check endpoint.","operationId":"health_check_api_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"Body_extract_narratives_api_extract_narratives_post":{"properties":{"file":{"type":"string","format":"binary","title":"File"},"sheets":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sheets"}},"type":"object","required":["file"],"title":"Body_extract_narratives_api_extract_narratives_post"},"ExtractionResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"file_name":{"type":"string","title":"File Name"},"file_type":{"type":"string","title":"File Type"},"question_count":{"type":"integer","title":"Question Count"},"questions":{"items":{"$ref":"#/components/schemas/NarrativeQuestionResponse"},"type":"array","title":"Questions"},"api_calls_used":{"type":"integer","title":"Api Calls Used"},"processing_time_seconds":{"type":"number","title":"Processing Time Seconds"}},"type":"object","required":["success","file_name","file_type","question_count","questions","api_calls_used","processing_time_seconds"],"title":"ExtractionResponse","description":"API response for narrative extraction."},"GenerateAnswerRequest":{"properties":{"question":{"type":"string","title":"Question"},"report_id":{"type":"integer","title":"Report Id"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"context":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Context"},"previous_answer":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Previous Answer"},"style":{"type":"string","title":"Style","default":"comprehensive"},"max_length":{"type":"integer","title":"Max Length","default":500}},"type":"object","required":["question","report_id"],"title":"GenerateAnswerRequest","description":"Request model for narrative answer generation."},"GenerateAnswerResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"generated_answer":{"type":"string","title":"Generated Answer"},"word_count":{"type":"integer","title":"Word Count"},"processing_time_seconds":{"type":"number","title":"Processing Time Seconds"},"refined_prompt":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Refined Prompt"},"responses_count":{"type":"integer","title":"Responses Count","default":0},"template_used":{"type":"boolean","title":"Template Used","default":false},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"}},"type":"object","required":["success","generated_answer","word_count","processing_time_seconds"],"title":"GenerateAnswerResponse","description":"Response model for narrative answer generation."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"IdentifyQuestionRequest":{"properties":{"questions":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Questions"}},"type":"object","required":["questions"],"title":"IdentifyQuestionRequest","description":"Request model for identifying the best identifier question in a form."},"IdentifyQuestionResponse":{"properties":{"question_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Question Id"}},"type":"object","title":"IdentifyQuestionResponse","description":"Response model for form question identification."},"NarrativeQuestionResponse":{"properties":{"narrative_question":{"type":"string","title":"Narrative Question"},"narrative_context":{"items":{"type":"string"},"type":"array","title":"Narrative Context"},"source_loc":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Loc"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"}},"type":"object","required":["narrative_question","narrative_context"],"title":"NarrativeQuestionResponse","description":"Individual extracted question."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}