Spaces:
Sleeping
Sleeping
Atharva Chauthaiwale
commited on
Commit
·
e5aa754
1
Parent(s):
f6cf3fe
Gradio app summary
Browse files- download_judgements.py +5 -0
- interpret_judgement.py +2 -2
- main.py +21 -3
download_judgements.py
CHANGED
@@ -79,3 +79,8 @@ def fetch_judgements():
|
|
79 |
logging.info(f"returned case objs {len(case_objs)}")
|
80 |
|
81 |
return case_objs
|
|
|
|
|
|
|
|
|
|
|
|
79 |
logging.info(f"returned case objs {len(case_objs)}")
|
80 |
|
81 |
return case_objs
|
82 |
+
|
83 |
+
def fetch_case_names():
|
84 |
+
case_objs = fetch_judgements()
|
85 |
+
names = [case['title'] for case in case_objs ]
|
86 |
+
return names
|
interpret_judgement.py
CHANGED
@@ -36,10 +36,10 @@ def download_dataset(url, save_folder="datasets", file_name=None):
|
|
36 |
return f"Failed to download dataset. Status code: {response.status_code}"
|
37 |
|
38 |
|
39 |
-
def interpret_judgement(case_url, file_name, title):
|
40 |
download_dataset(url=case_url, file_name=f"{file_name}.pdf")
|
41 |
documents = SimpleDirectoryReader("datasets").load_data()
|
42 |
index = VectorStoreIndex.from_documents(documents)
|
43 |
query_engine = index.as_query_engine()
|
44 |
-
return query_engine.query(f'''Intepret and
|
45 |
It should include information about petitioner, respondent and quick summary of order passed.''')
|
|
|
36 |
return f"Failed to download dataset. Status code: {response.status_code}"
|
37 |
|
38 |
|
39 |
+
def interpret_judgement(case_url, file_name='test', title=''):
|
40 |
download_dataset(url=case_url, file_name=f"{file_name}.pdf")
|
41 |
documents = SimpleDirectoryReader("datasets").load_data()
|
42 |
index = VectorStoreIndex.from_documents(documents)
|
43 |
query_engine = index.as_query_engine()
|
44 |
+
return query_engine.query(f'''Intepret and simplify the judegement {title} from given context. Convert it into a 3-4 line NEWS story format.
|
45 |
It should include information about petitioner, respondent and quick summary of order passed.''')
|
main.py
CHANGED
@@ -4,15 +4,33 @@ from slack_bolt import App
|
|
4 |
from slack_bolt.adapter.fastapi import SlackRequestHandler
|
5 |
import os
|
6 |
import logging
|
|
|
|
|
|
|
7 |
app = FastAPI()
|
8 |
|
9 |
-
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
app = gr.mount_gradio_app(app, io, path='/')
|
11 |
|
12 |
-
slack_app = App(token=os.environ.get("SLACK_BOT_TOKEN"),
|
|
|
13 |
app_handler = SlackRequestHandler(slack_app)
|
14 |
|
|
|
15 |
@app.post("/slack/events")
|
16 |
async def endpoint(req: Request):
|
17 |
logging.info('recevied slack event')
|
18 |
-
return await app_handler.handle(req)
|
|
|
4 |
from slack_bolt.adapter.fastapi import SlackRequestHandler
|
5 |
import os
|
6 |
import logging
|
7 |
+
from download_judgements import fetch_case_names
|
8 |
+
from interpret_judgement import interpret_judgement
|
9 |
+
|
10 |
app = FastAPI()
|
11 |
|
12 |
+
# io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
13 |
+
|
14 |
+
io = gr.Interface(
|
15 |
+
fn=interpret_judgement,
|
16 |
+
inputs=[
|
17 |
+
gr.Dropdown(
|
18 |
+
fetch_case_names(), label="Chose a case", info="Chose a case from latest Supreme Court judgements"
|
19 |
+
),
|
20 |
+
],
|
21 |
+
outputs=gr.outputs.Textbox(label="Summary"),
|
22 |
+
title="Judgement Buzz",
|
23 |
+
description="Your AI helper to interpret complex judgement from Supreme Court of India",
|
24 |
+
)
|
25 |
+
|
26 |
app = gr.mount_gradio_app(app, io, path='/')
|
27 |
|
28 |
+
slack_app = App(token=os.environ.get("SLACK_BOT_TOKEN"),
|
29 |
+
signing_secret=os.environ.get("SLACK_SIGNING_SECRET"))
|
30 |
app_handler = SlackRequestHandler(slack_app)
|
31 |
|
32 |
+
|
33 |
@app.post("/slack/events")
|
34 |
async def endpoint(req: Request):
|
35 |
logging.info('recevied slack event')
|
36 |
+
return await app_handler.handle(req)
|