Spaces:
Sleeping
Sleeping
namangupta2001
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
3 |
|
4 |
# Function to call your API
|
5 |
def call_jira_api(jira_ticket_header):
|
@@ -15,7 +16,14 @@ def call_jira_api(jira_ticket_header):
|
|
15 |
|
16 |
# Handle response
|
17 |
if response.status_code == 200:
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
else:
|
20 |
return f"Error {response.status_code}: {response.text}"
|
21 |
except Exception as e:
|
@@ -23,11 +31,12 @@ def call_jira_api(jira_ticket_header):
|
|
23 |
|
24 |
# Gradio Interface
|
25 |
iface = gr.Interface(
|
26 |
-
fn=call_jira_api,
|
27 |
inputs=gr.Textbox(label="Jira Ticket Header"), # Input field
|
28 |
-
outputs="
|
29 |
-
title="Jira Description Generator",
|
30 |
-
description="Enter the Jira ticket header to generate
|
|
|
31 |
)
|
32 |
|
33 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import json # Required for parsing nested JSON
|
4 |
|
5 |
# Function to call your API
|
6 |
def call_jira_api(jira_ticket_header):
|
|
|
16 |
|
17 |
# Handle response
|
18 |
if response.status_code == 200:
|
19 |
+
# Parse the API response
|
20 |
+
data = response.json()
|
21 |
+
# Parse the nested JSON in the "body" field
|
22 |
+
body = json.loads(data.get("body", "{}"))
|
23 |
+
# Extract the description field
|
24 |
+
description = body.get("description", "No description found.")
|
25 |
+
# Return description as plain text
|
26 |
+
return description
|
27 |
else:
|
28 |
return f"Error {response.status_code}: {response.text}"
|
29 |
except Exception as e:
|
|
|
31 |
|
32 |
# Gradio Interface
|
33 |
iface = gr.Interface(
|
34 |
+
fn=call_jira_api, # Function to call
|
35 |
inputs=gr.Textbox(label="Jira Ticket Header"), # Input field
|
36 |
+
outputs=gr.Textbox(label="Generated Description"), # Plain text output
|
37 |
+
title="Jira Description Generator",
|
38 |
+
description="Enter the Jira ticket header to generate the description.",
|
39 |
+
allow_flagging="never" # Disable flagging (removes the Flag button)
|
40 |
)
|
41 |
|
42 |
# Launch the app
|