acecalisto3 commited on
Commit
f4f6e16
·
verified ·
1 Parent(s): 990dfcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -64
app.py CHANGED
@@ -517,66 +517,31 @@ if __name__ == "__main__":
517
  signal.signal(signal.SIGTERM, signal_handler)
518
 
519
  # Create Gradio interface
520
- demo = create_gradio_interface()
521
-
522
- # Define Gradio endpoints
523
- def fetch_issues(github_token, repo_url):
524
- try:
525
- issues = bot.fetch_issues(github_token, repo_url.split('/')[-2], repo_url.split('/')[-1])
526
- return {'issues': issues}
527
- except Exception as e:
528
- return {'error': str(e)}
529
-
530
- def resolve_issue(github_token, repo_url, issue_number, resolution, forked_repo_url):
531
- try:
532
- result = handle_issue_selection(github_token, repo_url.split('/')[-2], repo_url.split('/')[-1], issue_number, resolution, forked_repo_url)
533
- return {'result': result}
534
- except Exception as e:
535
- return {'error': str(e)}
536
-
537
- def extract_info(url):
538
- try:
539
- info = extract_info_from_url(url)
540
- return info
541
- except Exception as e:
542
- return {'error': str(e)}
543
-
544
- def submit_issue(github_token, repo_url, issue_number, resolution, forked_repo_url):
545
- try:
546
- result = handle_issue_selection(github_token, repo_url.split('/')[-2], repo_url.split('/')[-1], issue_number, resolution, forked_repo_url)
547
- return {'result': result}
548
- except Exception as e:
549
- return {'error': str(e)}
550
-
551
- # Define Gradio interface
552
- demo = gr.Blocks()
553
- with demo:
554
  gr.HTML(custom_html)
555
-
556
- # Define all input components first
557
- with gr.Row():
558
- github_token_input = gr.Textbox(label="GitHub Token", type="password")
559
- repo_url_input = gr.Textbox(label="Repository URL")
560
-
561
- with gr.Row():
562
- issue_dropdown = gr.Dropdown(label="Select Issue", choices=[])
563
- resolution_textarea = gr.Textbox(label="Resolution", lines=3)
564
- forked_repo_url_input = gr.Textbox(label="Forked Repository URL")
565
-
566
- with gr.Row():
567
- output_area = gr.Textbox(label="Output", lines=5)
568
-
569
- url_textbox = gr.Textbox(label="URL to Extract Info")
570
-
571
- # Define buttons and their click events
572
- with gr.Row():
573
- fetch_issues_button = gr.Button("Fetch Issues")
574
- resolve_button = gr.Button("Resolve Issue")
575
- extract_info_button = gr.Button("Extract Info")
576
- submit_button = gr.Button("Submit")
577
-
578
- # Connect event handlers
579
- fetch_issues_button.click(
580
  fn=fetch_issues,
581
  inputs=[github_token_input, repo_url_input],
582
  outputs=output_area
@@ -584,11 +549,17 @@ if __name__ == "__main__":
584
 
585
  resolve_button.click(
586
  fn=resolve_issue,
587
- inputs=[github_token_input, repo_url_input, issue_dropdown, resolution_textarea, forked_repo_url_input],
 
 
 
 
 
 
588
  outputs=output_area
589
  )
590
 
591
- extract_info_button.click(
592
  fn=extract_info,
593
  inputs=[url_textbox],
594
  outputs=output_area
@@ -596,9 +567,20 @@ if __name__ == "__main__":
596
 
597
  submit_button.click(
598
  fn=submit_issue,
599
- inputs=[github_token_input, repo_url_input, issue_dropdown, resolution_textarea, forked_repo_url_input],
 
 
 
 
 
 
600
  outputs=output_area
601
  )
602
 
603
- if __name__ == "__main__":
604
- demo.launch(share=True)
 
 
 
 
 
 
517
  signal.signal(signal.SIGTERM, signal_handler)
518
 
519
  # Create Gradio interface
520
+ with gr.Blocks() as demo:
521
+ # Add HTML template
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  gr.HTML(custom_html)
523
+
524
+ # Create interface components that match the HTML IDs
525
+ with gr.Row(visible=True):
526
+ github_token_input = gr.Textbox(label="GitHub Token", elem_id="github-token")
527
+ repo_url_input = gr.Textbox(label="Repository URL", elem_id="repo-url")
528
+
529
+ with gr.Row(visible=True):
530
+ issue_dropdown = gr.Dropdown(label="Select Issue", elem_id="issue-dropdown")
531
+ resolution_textarea = gr.Textbox(label="Resolution", elem_id="resolution-textarea", lines=3)
532
+ forked_repo_url_input = gr.Textbox(label="Forked Repository URL", elem_id="forked-repo-url")
533
+
534
+ output_area = gr.Textbox(label="Output", elem_id="output-textarea", lines=5)
535
+ url_textbox = gr.Textbox(label="URL to Extract Info", elem_id="url-textbox")
536
+
537
+ # Define buttons with matching elem_ids
538
+ fetch_button = gr.Button("Fetch Issues", elem_id="fetch-issues")
539
+ resolve_button = gr.Button("Resolve Issue", elem_id="resolve-issue")
540
+ extract_button = gr.Button("Extract Info", elem_id="extract-info")
541
+ submit_button = gr.Button("Submit", elem_id="submit")
542
+
543
+ # Connect Python functions to buttons
544
+ fetch_button.click(
 
 
 
545
  fn=fetch_issues,
546
  inputs=[github_token_input, repo_url_input],
547
  outputs=output_area
 
549
 
550
  resolve_button.click(
551
  fn=resolve_issue,
552
+ inputs=[
553
+ github_token_input,
554
+ repo_url_input,
555
+ issue_dropdown,
556
+ resolution_textarea,
557
+ forked_repo_url_input
558
+ ],
559
  outputs=output_area
560
  )
561
 
562
+ extract_button.click(
563
  fn=extract_info,
564
  inputs=[url_textbox],
565
  outputs=output_area
 
567
 
568
  submit_button.click(
569
  fn=submit_issue,
570
+ inputs=[
571
+ github_token_input,
572
+ repo_url_input,
573
+ issue_dropdown,
574
+ resolution_textarea,
575
+ forked_repo_url_input
576
+ ],
577
  outputs=output_area
578
  )
579
 
580
+ # Launch the interface
581
+ demo.launch(
582
+ server_name="0.0.0.0",
583
+ server_port=7860,
584
+ share=True,
585
+ debug=True
586
+ )=True)