mirror of
https://github.com/Ladebeze66/llm_ticket3.git
synced 2025-12-15 20:06:51 +01:00
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
import json
|
|
from .base_agent import BaseAgent
|
|
from datetime import datetime
|
|
from typing import Dict, Any
|
|
|
|
class AgentReportGenerator(BaseAgent):
|
|
"""
|
|
Agent pour générer un rapport à partir des informations collectées.
|
|
"""
|
|
def __init__(self, llm):
|
|
super().__init__("AgentReportGenerator", llm)
|
|
|
|
def executer(self, rapport_data: Dict, filename: str):
|
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
|
#Sauvegarde json
|
|
json_path = f"../reports/json_reports/{filename}_{timestamp}.json"
|
|
with open(json_path, "w", encoding="utf-8") as f_json:
|
|
json.dump(rapport_data, f_json, ensure_ascii=False, indent=4)
|
|
|
|
#Sauvegarde Markdown
|
|
md_path =f"../repports/markdown_reports/{filename}_{timestamp}.md"
|
|
with open(md_path, "w", encoding="utf-8") as f_md:
|
|
f_md.write(f"# Rapport {filename}\n\n")
|
|
for key, value in rapport_data.items():
|
|
f_md.write(f"## {key.capitalize()}\n{value}\n\n")
|
|
|
|
self.ajouter_historique("generation_rapport", filename, "Rapport généré") |