File size: 1,156 Bytes
387c60c
 
08f9a45
3266f76
08f9a45
3266f76
 
08f9a45
a22a3a3
08f9a45
 
 
 
a74b6e2
 
 
08f9a45
 
 
 
 
 
 
 
 
 
387c60c
08f9a45
387c60c
3266f76
08f9a45
 
 
 
 
 
 
3266f76
387c60c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
import pymongo
import json

# Load insights from JSON file


def greet(session_id, user_id, query, jurisdiction, work_area):
    file=open('mydata.json', 'r')
    insights = json.load(file)
    message = None  # Initialize message variable
    # Search for the matching insight
    for insight in insights:
        if (insight.get('Title').lower() == query.lower() and 
            insight.get('Jurisdiction Insight').lower() == jurisdiction.lower() and 
            insight.get('Work Areas Art').lower() == work_area.lower()):
            message = insight.get('Content')
            break
    
    # Prepare response data
    if message is None:
        response = {'rada_response': 'No matching insight found.'}
    else:
        response = {'rada_response': str(message)}
    
    return response

# Create Gradio interface
demo = gr.Interface(
    fn=greet,
    inputs=[
        gr.Textbox(label="Session ID"),
        gr.Textbox(label="User ID"),
        gr.Textbox(label="Query"),
        gr.Textbox(label="Jurisdiction"),
        gr.Textbox(label="Work Area")
    ],
    outputs=gr.JSON(label="Generated JSON"),
)

demo.launch()