-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_generator.py
More file actions
61 lines (48 loc) · 1.37 KB
/
report_generator.py
File metadata and controls
61 lines (48 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
from groq import Groq
from typing import Dict, Any
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
def create_report(extracted: Dict[str, Any]) -> Dict[str, Any]:
inspection_text = extracted.get("inspection_text", "")
thermal_text = extracted.get("thermal_text", "")
prompt = f"""
You are an AI system generating a Detailed Diagnostic Report (DDR).
Use the following data:
Inspection Report:
{inspection_text}
Thermal Report:
{thermal_text}
Generate the report in JSON format using this structure:
{{
"property_issue_summary": "",
"area_wise_observations": [
{{
"area": "",
"observations": "",
"related_images": []
}}
],
"probable_root_cause": "",
"severity_assessment": "",
"recommended_actions": "",
"additional_notes": "",
"missing_or_unclear_information": ""
}}
Rules:
- Do NOT invent information
- If data is missing write "Not Available"
- Avoid duplicate observations
- Use simple client-friendly language
"""
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[
{"role": "system", "content": "You generate structured building inspection reports."},
{"role": "user", "content": prompt}
]
)
report = response.choices[0].message.content
return {
"report": report,
"images": extracted.get("images", [])
}