File size: 1,556 Bytes
0351e37
 
096f10f
0351e37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
096f10f
 
 
 
 
 
 
 
0351e37
 
 
 
 
 
 
096f10f
0351e37
096f10f
 
 
 
0351e37
 
 
 
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
42
43
44
import gradio as gr
import requests
import json  # Required for parsing nested JSON

# Function to call your API
def call_jira_api(jira_ticket_header):
    try:
        # Your API endpoint
        api_url = "https://znwkjn2kig.execute-api.us-east-1.amazonaws.com/dev"
        
        # Request payload
        payload = {"jira_ticket_header": jira_ticket_header}
        
        # Make the API call
        response = requests.post(api_url, json=payload)
        
        # Handle response
        if response.status_code == 200:
            # Parse the API response
            data = response.json()
            # Parse the nested JSON in the "body" field
            body = json.loads(data.get("body", "{}"))
            # Extract the description field
            description = body.get("description", "No description found.")
            # Return description as plain text
            return description
        else:
            return f"Error {response.status_code}: {response.text}"
    except Exception as e:
        return f"Error: {str(e)}"

# Gradio Interface
iface = gr.Interface(
    fn=call_jira_api,                          # Function to call
    inputs=gr.Textbox(label="Jira Ticket Header"),  # Input field
    outputs=gr.Textbox(label="Generated Description"),  # Plain text output
    title="Jira Description Generator",        
    description="Enter the Jira ticket header to generate the description.",
    allow_flagging="never"                     # Disable flagging (removes the Flag button)
)

# Launch the app
iface.launch()