Spaces:
Sleeping
Sleeping
Aiswarya Sankar
commited on
Commit
·
5db5c14
1
Parent(s):
f1fc3bd
Refactor stuff
Browse files
app.py
CHANGED
@@ -84,6 +84,12 @@ tickets = []
|
|
84 |
|
85 |
repo_name = gr.State()
|
86 |
git_tickets = gr.State()
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
# repoName = "https://github.com/gradio-app/gradio.git"
|
88 |
|
89 |
embeddings = OpenAIEmbeddings(disallowed_special=())
|
@@ -190,7 +196,6 @@ def index_repo(textbox: str, dropdown: str) -> Response:
|
|
190 |
stdout="",
|
191 |
)
|
192 |
|
193 |
-
# global ticket_choices, ticket_titles, tickets
|
194 |
repo = "/".join(repo[:-4].split("/")[-2:])
|
195 |
tickets = fetchGithubIssues(repo, 10)
|
196 |
git_tickets.value = tickets
|
@@ -206,7 +211,6 @@ def index_repo(textbox: str, dropdown: str) -> Response:
|
|
206 |
|
207 |
def answer_questions(question: str, github: str, **kwargs) -> Response:
|
208 |
|
209 |
-
# global repoName
|
210 |
repoName = repo_name.value
|
211 |
github = repoName[:-4]
|
212 |
print("REPO NAME: " + github)
|
@@ -258,11 +262,11 @@ def answer_questions(question: str, github: str, **kwargs) -> Response:
|
|
258 |
)
|
259 |
|
260 |
|
261 |
-
def fetchGithubIssues(
|
262 |
"""
|
263 |
This endpoint should get a list of all the github issues that are open for this repository
|
264 |
"""
|
265 |
-
|
266 |
batch = []
|
267 |
all_issues = []
|
268 |
per_page = 100 # Number of issues to return per page
|
@@ -288,6 +292,10 @@ def fetchGithubIssues(repo: str, num_issues:int, **kwargs) -> Response:
|
|
288 |
"comments_url": issue["comments_url"],
|
289 |
})
|
290 |
|
|
|
|
|
|
|
|
|
291 |
return issues_data
|
292 |
|
293 |
|
@@ -368,13 +376,13 @@ def solveGithubIssue(ticket, history) -> Response:
|
|
368 |
"""
|
369 |
# global repoName
|
370 |
repoName = repo_name.value
|
371 |
-
ticket_choices = git_tickets.value
|
372 |
# global ticket_choices
|
373 |
github = repoName[:-4]
|
374 |
|
375 |
repoFolder = github.split("/")[-1]
|
376 |
-
body =
|
377 |
-
title =
|
378 |
question = """
|
379 |
Given the code in the {} repo, propose a solution for this ticket {} that includes a
|
380 |
high level implementation, narrowing down the root cause of the issue and psuedocode if
|
@@ -487,9 +495,6 @@ with gr.Blocks() as demo:
|
|
487 |
|
488 |
success_response = gr.Textbox(label="")
|
489 |
ingest_btn = gr.Button("Index repo")
|
490 |
-
# ticketDropdown = gr.Dropdown()
|
491 |
-
|
492 |
-
# repoTextBox.submit(fetchGithubIssues, [], ticketDropdown)
|
493 |
|
494 |
with gr.Column(visible=False) as launch_product:
|
495 |
|
@@ -509,35 +514,30 @@ with gr.Blocks() as demo:
|
|
509 |
with gr.Tab("Bug Triage"):
|
510 |
|
511 |
# Display the titles in the dropdown
|
512 |
-
def create_ticket_dropdown(
|
|
|
|
|
|
|
513 |
|
|
|
514 |
return gr.Dropdown.update(
|
515 |
choices=ticket_titles, value=ticket_titles[0]
|
516 |
), gr.update(visible=True)
|
517 |
|
518 |
# global ticket_choices, ticket_titles, tickets
|
519 |
-
repo = "/".join(repo_name.value[:-4].split("/")[-2:])
|
520 |
-
tickets = fetchGithubIssues(repo, 10)
|
521 |
|
522 |
# Create the dropdown
|
523 |
-
ticket_choices = {
|
524 |
-
ticket_titles = [
|
525 |
-
|
526 |
-
|
527 |
-
# repo = gr.Interface.get_session_state("repo")
|
528 |
-
# repo = "/".join(repoName[:-4].split("/")[-2:])
|
529 |
-
# tickets = fetchGithubIssues(repo, 10)
|
530 |
-
|
531 |
-
# # Create the dropdown
|
532 |
-
# global ticket_choices
|
533 |
-
ticket_choices = {ticket["title"]: ticket for ticket in tickets}
|
534 |
-
ticket_titles = [ticket["title"] for ticket in tickets]
|
535 |
-
|
536 |
-
ticketDropdown = gr.Dropdown(choices=ticket_titles, title="Github Issues")
|
537 |
|
538 |
# Extract the ticket title, body for the selected ticket
|
539 |
chatbot = gr.Chatbot()
|
540 |
msg = gr.Textbox()
|
|
|
541 |
clear = gr.Button("Clear")
|
542 |
|
543 |
ticketDropdown.change(solveGithubIssue, inputs=[ticketDropdown, chatbot], outputs=[chatbot])
|
@@ -650,7 +650,7 @@ with gr.Blocks() as demo:
|
|
650 |
)
|
651 |
|
652 |
|
653 |
-
ingest_btn.click(fn=index_repo, inputs=[repoTextBox, ingestedRepos], outputs=[success_response, launch_product], api_name="index_repo")
|
654 |
# ingest_btn.click(fn=)
|
655 |
|
656 |
|
|
|
84 |
|
85 |
repo_name = gr.State()
|
86 |
git_tickets = gr.State()
|
87 |
+
git_titles = gr.State()
|
88 |
+
git_ticket_choices = gr.State()
|
89 |
+
git_tickets.value = []
|
90 |
+
git_titles.value = []
|
91 |
+
git_ticket_choices.value = []
|
92 |
+
|
93 |
# repoName = "https://github.com/gradio-app/gradio.git"
|
94 |
|
95 |
embeddings = OpenAIEmbeddings(disallowed_special=())
|
|
|
196 |
stdout="",
|
197 |
)
|
198 |
|
|
|
199 |
repo = "/".join(repo[:-4].split("/")[-2:])
|
200 |
tickets = fetchGithubIssues(repo, 10)
|
201 |
git_tickets.value = tickets
|
|
|
211 |
|
212 |
def answer_questions(question: str, github: str, **kwargs) -> Response:
|
213 |
|
|
|
214 |
repoName = repo_name.value
|
215 |
github = repoName[:-4]
|
216 |
print("REPO NAME: " + github)
|
|
|
262 |
)
|
263 |
|
264 |
|
265 |
+
def fetchGithubIssues(num_issues:int, **kwargs) -> Response:
|
266 |
"""
|
267 |
This endpoint should get a list of all the github issues that are open for this repository
|
268 |
"""
|
269 |
+
repo = repo_name.value
|
270 |
batch = []
|
271 |
all_issues = []
|
272 |
per_page = 100 # Number of issues to return per page
|
|
|
292 |
"comments_url": issue["comments_url"],
|
293 |
})
|
294 |
|
295 |
+
# This should set the state variables for tickets
|
296 |
+
git_tickets.value = issues_data
|
297 |
+
git_ticket_choices.value = {git_tickets.value["title"]: ticket for ticket in tickets}
|
298 |
+
git_titles.value = [git_tickets.value["title"] for ticket in tickets]
|
299 |
return issues_data
|
300 |
|
301 |
|
|
|
376 |
"""
|
377 |
# global repoName
|
378 |
repoName = repo_name.value
|
379 |
+
# ticket_choices = git_tickets.value
|
380 |
# global ticket_choices
|
381 |
github = repoName[:-4]
|
382 |
|
383 |
repoFolder = github.split("/")[-1]
|
384 |
+
body = git_ticket_choices.value[ticket]["body"]
|
385 |
+
title = git_ticket_choices.value[ticket]["title"]
|
386 |
question = """
|
387 |
Given the code in the {} repo, propose a solution for this ticket {} that includes a
|
388 |
high level implementation, narrowing down the root cause of the issue and psuedocode if
|
|
|
495 |
|
496 |
success_response = gr.Textbox(label="")
|
497 |
ingest_btn = gr.Button("Index repo")
|
|
|
|
|
|
|
498 |
|
499 |
with gr.Column(visible=False) as launch_product:
|
500 |
|
|
|
514 |
with gr.Tab("Bug Triage"):
|
515 |
|
516 |
# Display the titles in the dropdown
|
517 |
+
def create_ticket_dropdown():
|
518 |
+
|
519 |
+
ticket_choices = {git_tickets.value["title"]: ticket for ticket in tickets}
|
520 |
+
ticket_titles = [git_tickets.value["title"] for ticket in tickets]
|
521 |
|
522 |
+
# return ticket_choices, ticket_titles
|
523 |
return gr.Dropdown.update(
|
524 |
choices=ticket_titles, value=ticket_titles[0]
|
525 |
), gr.update(visible=True)
|
526 |
|
527 |
# global ticket_choices, ticket_titles, tickets
|
528 |
+
# repo = "/".join(repo_name.value[:-4].split("/")[-2:])
|
529 |
+
# tickets = fetchGithubIssues(repo, 10)
|
530 |
|
531 |
# Create the dropdown
|
532 |
+
# ticket_choices = {git_tickets.value["title"]: ticket for ticket in tickets}
|
533 |
+
# ticket_titles = [git_tickets.value["title"] for ticket in tickets]
|
534 |
+
ingestTickets = gr.Button("Ingest github tickets").submit(fetchGithubIssues, inputs=[20], outputs=[]).then(create_ticket_dropdown)
|
535 |
+
ticketDropdown = gr.Dropdown(choices=git_titles.value, title="Github Issues")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
|
537 |
# Extract the ticket title, body for the selected ticket
|
538 |
chatbot = gr.Chatbot()
|
539 |
msg = gr.Textbox()
|
540 |
+
|
541 |
clear = gr.Button("Clear")
|
542 |
|
543 |
ticketDropdown.change(solveGithubIssue, inputs=[ticketDropdown, chatbot], outputs=[chatbot])
|
|
|
650 |
)
|
651 |
|
652 |
|
653 |
+
ingest_btn.click(fn=index_repo, inputs=[repoTextBox, ingestedRepos], outputs=[success_response, launch_product], api_name="index_repo").then(fn=fetchGithubIssues, inputs=[20], outputs=[])
|
654 |
# ingest_btn.click(fn=)
|
655 |
|
656 |
|