Spaces:
Sleeping
Sleeping
Update document_generator.py
Browse files- document_generator.py +25 -0
document_generator.py
CHANGED
|
@@ -281,6 +281,31 @@ async def generate_document_endpoint(request: DocumentRequest):
|
|
| 281 |
except Exception as e:
|
| 282 |
raise HTTPException(status_code=500, detail=str(e))
|
| 283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
class CacheTestResponse(BaseModel):
|
| 285 |
result: str
|
| 286 |
execution_time: float
|
|
|
|
| 281 |
except Exception as e:
|
| 282 |
raise HTTPException(status_code=500, detail=str(e))
|
| 283 |
|
| 284 |
+
|
| 285 |
+
@app.post("/generate-document-test", response_model=DocumentResponse)
|
| 286 |
+
async def test_generate_document_endpoint(request: DocumentRequest):
|
| 287 |
+
try:
|
| 288 |
+
# Load JSON document from file
|
| 289 |
+
json_path = os.path.join("output/document_generator", "ai-chatbot-prd.json")
|
| 290 |
+
with open(json_path, "r") as json_file:
|
| 291 |
+
json_document = json.load(json_file)
|
| 292 |
+
|
| 293 |
+
# Load Markdown document from file
|
| 294 |
+
md_path = os.path.join("output/document_generator", "ai-chatbot-prd.md")
|
| 295 |
+
with open(md_path, "r") as md_file:
|
| 296 |
+
markdown_document = md_file.read()
|
| 297 |
+
|
| 298 |
+
return DocumentResponse(
|
| 299 |
+
json_document=json_document,
|
| 300 |
+
markdown_document=markdown_document
|
| 301 |
+
)
|
| 302 |
+
except FileNotFoundError:
|
| 303 |
+
raise HTTPException(status_code=404, detail="Test files not found")
|
| 304 |
+
except json.JSONDecodeError:
|
| 305 |
+
raise HTTPException(status_code=500, detail="Error parsing JSON file")
|
| 306 |
+
except Exception as e:
|
| 307 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 308 |
+
|
| 309 |
class CacheTestResponse(BaseModel):
|
| 310 |
result: str
|
| 311 |
execution_time: float
|