File size: 1,164 Bytes
1796c2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 streamlit as st
from backend import JSONPath_Generator


class JSONQuery_Frontend:
    def __init__(self):
        pass

    def run(self):
        self.titleheader()
        self.input_text()
        self.submit_btn()

    def titleheader(self):
        # Initialize Streamlit app
        st.set_page_config(page_title="👨‍💻 JSON Path Generator")
        st.header("JSON Path Generator")


    def input_text(self):
        # Input Text Area
        self.open_ai_key = st.text_input(label="Enter the OpenAI Key: ")
        self.json_value = st.text_area(label="JSON Body Input: ")
        self.target_input = st.text_input(label="Target JSON Key: ")
        self.json_condition = st.text_input(label="JSON Conditions (If any): ")

    def submit_btn(self):
        if st.button("Submit"):
            self.json_path_gen = JSONPath_Generator(json_input=self.json_value, target_value=self.target_input,
                                               json_condition=self.json_condition,
                                               openai_key=self.open_ai_key)
            res = self.json_path_gen.create_llm_chain()
            st.write(res)