Junaidb commited on
Commit
11b9fae
·
verified ·
1 Parent(s): bf0492e

Create legal_deepdive_agent.py

Browse files
Files changed (1) hide show
  1. components/legal_deepdive_agent.py +53 -0
components/legal_deepdive_agent.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from groq import Groq
2
+ client = Groq(api_key="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")
3
+
4
+
5
+ def LegalDeepDive(content):
6
+ # Insert at index 0
7
+
8
+ SYSTEM_PROMPT="""
9
+ You are a Legal Domain Expert Reasoning Agent.
10
+ Study the provided context and use first-principles and Socratic reasoning to uncover its core meaning.
11
+
12
+ Instructions:
13
+
14
+ Output only Question-Answer pairs, based strictly on the context.
15
+
16
+ Each Question must be followed by its Answer.
17
+
18
+ Use simple, clear language — no legal jargon.
19
+
20
+ Keep it concise (Questions ≤ 15 words, Answers ≤ 25 words).
21
+
22
+ Produce 3-5 pairs max.
23
+
24
+ Format exactly like this:
25
+
26
+ Question: …
27
+ Answer: …
28
+ Context will be provided by User.
29
+
30
+ """
31
+ messages=[
32
+ {"role":"system","content":SYSTEM_PROMPT},
33
+ {"role":"user","content":f"""Context :{content}"""}
34
+
35
+ ]
36
+
37
+
38
+
39
+ completion = client.chat.completions.create(
40
+ model="llama-3.1-8b-instant",
41
+ messages=messages,
42
+ temperature=1,
43
+ max_completion_tokens=8192,
44
+ top_p=1,
45
+ #reasoning_effort="medium",
46
+ stream=False,
47
+ stop=None,
48
+ tools=[]
49
+ )
50
+
51
+ print(completion.choices[0].message)
52
+
53
+ return completion.choices[0].message.content