JARVISXIRONMAN commited on
Commit
1d71e84
·
verified ·
1 Parent(s): 38dc299

Create agents/draft_agent.py

Browse files
Files changed (1) hide show
  1. agents/draft_agent.py +44 -0
agents/draft_agent.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agents/draft_agent.py
2
+
3
+ import os
4
+ from openai import OpenAI
5
+ from dotenv import load_dotenv
6
+
7
+ # Load .env file
8
+ load_dotenv()
9
+
10
+ # Setup Groq client
11
+ client = OpenAI(
12
+ base_url=os.getenv("GROQ_BASE_URL"),
13
+ api_key=os.getenv("GROQ_API_KEY")
14
+ )
15
+
16
+ def generate_notice(clause_text, recipient="Tenant"):
17
+ prompt = f"""
18
+ You are a legal assistant that helps draft formal legal notices in both English and Urdu.
19
+
20
+ Based on the clause below, generate a short, polite, but legally valid notice letter for the recipient.
21
+
22
+ Clause:
23
+ {clause_text}
24
+
25
+ Recipient: {recipient}
26
+
27
+ Output:
28
+ 1. 📄 English Legal Notice
29
+ 2. 📄 اردو قانونی نوٹس (سادہ اور رسمی زبان میں)
30
+ """
31
+
32
+ response = client.chat.completions.create(
33
+ model="llama3-70b-8192",
34
+ messages=[{"role": "user", "content": prompt}],
35
+ temperature=0.4,
36
+ )
37
+
38
+ return response.choices[0].message.content
39
+
40
+
41
+ # Optional test run
42
+ if __name__ == "__main__":
43
+ clause = "شق 7: کرایہ دار کو 30 دن کے اندر مکان خالی کرنا ہوگا ورنہ قانونی کارروائی ہو سکتی ہے۔"
44
+ print(generate_notice(clause, recipient="کرایہ دار"))