Spaces:
Sleeping
Sleeping
Download app/controllers/lm_controller.py from Liantsoaxx08/LMGenerator: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/Liantsoaxx08/LMGenerator/resolve/main/app/controllers/lm_controller.py
- Command line
-
hf download hf://spaces/Liantsoaxx08/LMGenerator/app/controllers/lm_controller.py
-
curl -L -o lm_controller.py https://huggingface.co/spaces/Liantsoaxx08/LMGenerator/resolve/main/app/controllers/lm_controller.py
1.1 kB
| from fastapi import APIRouter, HTTPException | |
| from app.models.lm_generator import AiAgentLMGenerator | |
| from app.models.docx_generator import DocxGenerator | |
| from pydantic import BaseModel | |
| router = APIRouter() | |
| class LMRequest(BaseModel): | |
| name: str | |
| job: str | |
| job_description: str | |
| email: str | |
| phone: str | |
| competences: list[str] | |
| github_url: str = None | |
| linkedin_url: str = None | |
| class DocxRequest(BaseModel): | |
| lm_content: str | |
| def generate_lm_content(request: LMRequest): | |
| try: | |
| generator = AiAgentLMGenerator() | |
| user_data = request.dict() | |
| content = generator.generate(user_data) | |
| return {"lm_content": content} | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| def generate_docx(request: DocxRequest): | |
| try: | |
| docx_gen = DocxGenerator() | |
| docx_file = docx_gen.generate_docx(request.lm_content) | |
| return {"docx_file": docx_file} | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |