Chit1324 commited on
Commit
1f883cc
·
verified ·
1 Parent(s): 160d33a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Function to call the "Previous Cases" API (cts endpoint)
5
+ def previous_cases(query):
6
+ try:
7
+ response = requests.post("https://aaronanoronha-haha.hf.space/cts", json={"topic": query})
8
+ return response.text
9
+ except Exception as e:
10
+ return f"Error: {e}"
11
+
12
+ # Function to call the "Law Navigation" API (lsi endpoint)
13
+ def law_navigation(query):
14
+ try:
15
+ response = requests.post("https://aaronanoronha-haha.hf.space/lsi", json={"topic": query})
16
+ return response.text
17
+ except Exception as e:
18
+ return f"Error: {e}"
19
+
20
+ # Function to call the "Judgment Prediction" API (pcr endpoint)
21
+ def judgment_prediction(query):
22
+ try:
23
+ response = requests.post("https://aaronanoronha-haha.hf.space/pcr", json={"topic": query})
24
+ return response.text
25
+ except Exception as e:
26
+ return f"Error: {e}"
27
+
28
+ # Function to call the "Bail Analysis" API (bail endpoint)
29
+ def bail_analysis(query):
30
+ try:
31
+ response = requests.post("https://aaronanoronha-haha.hf.space/bail", json={"topic": query})
32
+ return response.text
33
+ except Exception as e:
34
+ return f"Error: {e}"
35
+
36
+ # Create a Gradio Blocks interface with tabs for each API
37
+ with gr.Blocks() as demo:
38
+ gr.Markdown("# Legal AI Assistant")
39
+ with gr.Tabs():
40
+ with gr.TabItem("Previous Cases"):
41
+ input_text = gr.Textbox(lines=3, placeholder="Enter your query...", label="Query")
42
+ output_text = gr.Textbox(lines=10, label="Response")
43
+ gr.Button("Submit").click(fn=previous_cases, inputs=input_text, outputs=output_text)
44
+
45
+ with gr.TabItem("Law Navigation"):
46
+ input_text2 = gr.Textbox(lines=3, placeholder="Enter your query...", label="Query")
47
+ output_text2 = gr.Textbox(lines=10, label="Response")
48
+ gr.Button("Submit").click(fn=law_navigation, inputs=input_text2, outputs=output_text2)
49
+
50
+ with gr.TabItem("Judgment Prediction"):
51
+ input_text3 = gr.Textbox(lines=3, placeholder="Enter your query...", label="Query")
52
+ output_text3 = gr.Textbox(lines=10, label="Response")
53
+ gr.Button("Submit").click(fn=judgment_prediction, inputs=input_text3, outputs=output_text3)
54
+
55
+ with gr.TabItem("Bail Analysis"):
56
+ input_text4 = gr.Textbox(lines=3, placeholder="Enter your query...", label="Query")
57
+ output_text4 = gr.Textbox(lines=10, label="Response")
58
+ gr.Button("Submit").click(fn=bail_analysis, inputs=input_text4, outputs=output_text4)
59
+
60
+ demo.launch()