namangupta2001 commited on
Commit
096f10f
·
verified ·
1 Parent(s): ac40de7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
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
- return response.json()
 
 
 
 
 
 
 
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, # Function to call
27
  inputs=gr.Textbox(label="Jira Ticket Header"), # Input field
28
- outputs="text", # Output as text
29
- title="Jira Description Generator",
30
- description="Enter the Jira ticket header to generate a description."
 
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