RoAr777 commited on
Commit
0297631
Β·
verified Β·
1 Parent(s): a06da67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -16
app.py CHANGED
@@ -10,6 +10,29 @@ import os
10
  import pytesseract
11
  from PIL import Image
12
  pytesseract.pytesseract.tesseract_cmd = r"tesseract.exe"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  llm = ChatGoogleGenerativeAI(
15
  model="gemini-1.5-pro",
@@ -26,19 +49,6 @@ llm = ChatGoogleGenerativeAI(
26
 
27
  Example task: "What is the punishment for theft according to the IPC?"
28
  Example response: "According to Section 379 of the IPC, the punishment for theft is imprisonment of either description for a term which may extend to three years, or with fine, or with both."
29
- IPC in gist:
30
- Title and Scope: The Indian Penal Code applies to the whole of India, except for the State of Jammu and Kashmir. It dictates punishments for acts or omissions that violate its provisions.●
31
- General Explanations: The document provides definitions for various terms used throughout the code, such as "public," "servant of Government," "Government," "India," "Judge," "Court of Justice," and "moveable property."●
32
- Punishments: The Indian Penal Code outlines six categories of punishment: death, imprisonment for life, imprisonment (rigorous or simple), forfeiture of property, and fine.●
33
- Offenses Against the State: These include waging war against the Government of India, sedition, and offenses relating to the Army, Navy, and Air Force.●
34
- Offenses Against Public Tranquility: This category encompasses unlawful assembly, rioting, and affray (fighting in a public place).●
35
- Offenses By or Relating to Public Servants: This section covers offenses such as public servants disobeying the law, engaging in unlawful trade, and framing incorrect documents.●
36
- Offenses Relating to Documents and Property Marks: This part deals with forgery, using forged documents, counterfeiting, and offenses related to property marks.●
37
- Criminal Breach of Contracts of Service: The code addresses breaches of contract related to attending to helpless individuals.●
38
- Offenses Relating to Marriage: This section covers offenses such as causing a woman to cohabit based on deceitful marriage, marrying again while a spouse is alive, and concealing a previous marriage.●
39
- Defamation: The code defines defamation and includes exceptions for publications made in good faith, such as court reports, opinions on decided cases, and cautions conveyed for the good of others.●
40
- Criminal Intimidation, Insult, and Annoyance: This section addresses criminal intimidation, intentional insult to provoke breach of peace, statements conducing to public mischief, and statements promoting enmity between classes.
41
-
42
 
43
  Task: {{query}}
44
 
@@ -46,9 +56,12 @@ Criminal Intimidation, Insult, and Annoyance: This section addresses criminal in
46
  """,
47
  )
48
 
49
- agent = create_react_agent(
50
- llm=llm,
51
-
 
 
 
52
  verbose=True,
53
  return_intermediate_steps=True,
54
  handle_parsing_errors=True,
 
10
  import pytesseract
11
  from PIL import Image
12
  pytesseract.pytesseract.tesseract_cmd = r"tesseract.exe"
13
+ def retrieve_info():
14
+ return """IPC in gist:
15
+ Title and Scope: The Indian Penal Code applies to the whole of India, except for the State of Jammu and Kashmir. It dictates punishments for acts or omissions that violate its provisions.●
16
+ General Explanations: The document provides definitions for various terms used throughout the code, such as "public," "servant of Government," "Government," "India," "Judge," "Court of Justice," and "moveable property."●
17
+ Punishments: The Indian Penal Code outlines six categories of punishment: death, imprisonment for life, imprisonment (rigorous or simple), forfeiture of property, and fine.●
18
+ Offenses Against the State: These include waging war against the Government of India, sedition, and offenses relating to the Army, Navy, and Air Force.●
19
+ Offenses Against Public Tranquility: This category encompasses unlawful assembly, rioting, and affray (fighting in a public place).●
20
+ Offenses By or Relating to Public Servants: This section covers offenses such as public servants disobeying the law, engaging in unlawful trade, and framing incorrect documents.●
21
+ Offenses Relating to Documents and Property Marks: This part deals with forgery, using forged documents, counterfeiting, and offenses related to property marks.●
22
+ Criminal Breach of Contracts of Service: The code addresses breaches of contract related to attending to helpless individuals.●
23
+ Offenses Relating to Marriage: This section covers offenses such as causing a woman to cohabit based on deceitful marriage, marrying again while a spouse is alive, and concealing a previous marriage.●
24
+ Defamation: The code defines defamation and includes exceptions for publications made in good faith, such as court reports, opinions on decided cases, and cautions conveyed for the good of others.●
25
+ Criminal Intimidation, Insult, and Annoyance: This section addresses criminal intimidation, intentional insult to provoke breach of peace, statements conducing to public mischief, and statements promoting enmity between classes.
26
+ """
27
+
28
+
29
+
30
+ ipc_tool = Tool(
31
+ name="IPC Information Retrieval",
32
+ func=retrieve_info,
33
+ description="Provides IPC Gist.No parameter required."
34
+ )
35
+
36
 
37
  llm = ChatGoogleGenerativeAI(
38
  model="gemini-1.5-pro",
 
49
 
50
  Example task: "What is the punishment for theft according to the IPC?"
51
  Example response: "According to Section 379 of the IPC, the punishment for theft is imprisonment of either description for a term which may extend to three years, or with fine, or with both."
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  Task: {{query}}
54
 
 
56
  """,
57
  )
58
 
59
+ agent_tools = [ipc_tool]
60
+
61
+ agent = initialize_agent(
62
+ tools=agent_tools,
63
+ llm=llm,
64
+ agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
65
  verbose=True,
66
  return_intermediate_steps=True,
67
  handle_parsing_errors=True,