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

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,11 +1,13 @@
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
 
@@ -13,7 +15,8 @@ def previous_cases(query):
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
 
@@ -21,7 +24,8 @@ def law_navigation(query):
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
 
@@ -29,7 +33,8 @@ def judgment_prediction(query):
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
 
 
1
  import gradio as gr
2
  import requests
3
+ import json # Import json module to parse response text
4
 
5
  # Function to call the "Previous Cases" API (cts endpoint)
6
  def previous_cases(query):
7
  try:
8
  response = requests.post("https://aaronanoronha-haha.hf.space/cts", json={"topic": query})
9
+ data = json.loads(response.text) # Parse JSON string into dictionary
10
+ return data.get("response", "No response found") # Extract 'response' field
11
  except Exception as e:
12
  return f"Error: {e}"
13
 
 
15
  def law_navigation(query):
16
  try:
17
  response = requests.post("https://aaronanoronha-haha.hf.space/lsi", json={"topic": query})
18
+ data = json.loads(response.text)
19
+ return data.get("response", "No response found")
20
  except Exception as e:
21
  return f"Error: {e}"
22
 
 
24
  def judgment_prediction(query):
25
  try:
26
  response = requests.post("https://aaronanoronha-haha.hf.space/pcr", json={"topic": query})
27
+ data = json.loads(response.text)
28
+ return data.get("response", "No response found")
29
  except Exception as e:
30
  return f"Error: {e}"
31
 
 
33
  def bail_analysis(query):
34
  try:
35
  response = requests.post("https://aaronanoronha-haha.hf.space/bail", json={"topic": query})
36
+ data = json.loads(response.text)
37
+ return data.get("response", "No response found")
38
  except Exception as e:
39
  return f"Error: {e}"
40