Spaces:
Sleeping
Sleeping
Amy Roberts
commited on
Commit
·
18ec458
1
Parent(s):
c1fc690
Tidy up
Browse files- app.py +40 -8
- get_issues.py → build_saved_issues.py +0 -0
- get_topic.py +1 -1
- update_stored_issues.py +2 -2
app.py
CHANGED
@@ -1,9 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from find_similar_issues import get_similar_issues
|
3 |
import requests
|
4 |
|
5 |
from defaults import OWNER, REPO
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def get_query_issue_information(issue_no, token):
|
9 |
headers = {
|
@@ -35,24 +44,47 @@ def run_find_similar_issues(token, n_issues, issue_no, query):
|
|
35 |
return issues_html
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
with gr.Blocks(title="Github Bot") as demo:
|
39 |
with gr.Tab("Find similar issues"):
|
40 |
with gr.Row():
|
|
|
41 |
with gr.Column():
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
49 |
with gr.Row():
|
50 |
-
|
51 |
|
52 |
with gr.Row():
|
53 |
with gr.Row():
|
54 |
issues_html = gr.HTML(label="Issue text", elem_id="issue_html")
|
55 |
-
with gr.Row():
|
56 |
submit_button.click(run_find_similar_issues, outputs=[issues_html], inputs=[token, n_issues, issue_no, query])
|
57 |
|
58 |
with gr.Tab("Find maintainers to ping"):
|
|
|
1 |
+
import datetime
|
2 |
import gradio as gr
|
3 |
+
import os
|
4 |
from find_similar_issues import get_similar_issues
|
5 |
import requests
|
6 |
|
7 |
from defaults import OWNER, REPO
|
8 |
|
9 |
+
from build_saved_issues import get_issues
|
10 |
+
from update_stored_issues import update_issues
|
11 |
+
import build_issue_dict
|
12 |
+
import build_embeddings
|
13 |
+
import shutil
|
14 |
+
|
15 |
+
|
16 |
|
17 |
def get_query_issue_information(issue_no, token):
|
18 |
headers = {
|
|
|
44 |
return issues_html
|
45 |
|
46 |
|
47 |
+
def update_issues():
|
48 |
+
# Archive the stored issues
|
49 |
+
if os.path.exists("issues.json"):
|
50 |
+
date_time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
51 |
+
shutil.copy("issues.json", f"{date_time}_issues.json")
|
52 |
+
|
53 |
+
# Retrieve new issues
|
54 |
+
get_issues(overwrite=False, update=True, output_filename="issues.json")
|
55 |
+
# Update any issues that have been updated since the last update
|
56 |
+
update_issues()
|
57 |
+
# Update the dictionary of issues
|
58 |
+
build_issue_dict.build_json_file("issues.json", "issues_dict.json")
|
59 |
+
# Update the embeddings
|
60 |
+
build_embeddings.embed_issues(
|
61 |
+
input_filename="issues_dict.json",
|
62 |
+
issue_type="issue",
|
63 |
+
model_id="all-mpnet-base-v2",
|
64 |
+
update=True
|
65 |
+
)
|
66 |
+
|
67 |
+
|
68 |
with gr.Blocks(title="Github Bot") as demo:
|
69 |
with gr.Tab("Find similar issues"):
|
70 |
with gr.Row():
|
71 |
+
# with gr.Column():
|
72 |
with gr.Column():
|
73 |
+
gr.Markdown("Find similar issues to a given issue or query")
|
74 |
+
issue_no = gr.Textbox(label="Github Issue", placeholder="Github issue you want to find similar issues to")
|
75 |
+
query = gr.Textbox(label="Query", placeholder="Search for issues")
|
76 |
+
with gr.Column():
|
77 |
+
token = gr.Textbox(label="Github Token", placeholder="Your github token for authentication. This is not stored anywhere.")
|
78 |
+
n_issues = gr.Slider(1, 50, value=5, step=1, label="Number of similar issues", info="Choose between 1 and 50")
|
79 |
+
update_button = gr.Button(value="Update issues")
|
80 |
+
update_button.click(update_issues)
|
81 |
|
82 |
with gr.Row():
|
83 |
+
submit_button = gr.Button(value="Submit")
|
84 |
|
85 |
with gr.Row():
|
86 |
with gr.Row():
|
87 |
issues_html = gr.HTML(label="Issue text", elem_id="issue_html")
|
|
|
88 |
submit_button.click(run_find_similar_issues, outputs=[issues_html], inputs=[token, n_issues, issue_no, query])
|
89 |
|
90 |
with gr.Tab("Find maintainers to ping"):
|
get_issues.py → build_saved_issues.py
RENAMED
File without changes
|
get_topic.py
CHANGED
@@ -44,7 +44,7 @@ model = LlamaForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
|
|
44 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
|
45 |
|
46 |
# prompt = f"Which of the following topics {list(topic_maintainers_map.keys())} is this issue about:\n{issue['body']}"
|
47 |
-
prompt = f"What is the provided issue about? Pick up to 3 topics from the following list: {list(topic_maintainers_map.keys())} \
|
48 |
inputs = tokenizer(prompt, return_tensors="pt")
|
49 |
|
50 |
prefix_len = inputs.input_ids.shape[1]
|
|
|
44 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
|
45 |
|
46 |
# prompt = f"Which of the following topics {list(topic_maintainers_map.keys())} is this issue about:\n{issue['body']}"
|
47 |
+
prompt = f"QUESTION: What is the provided issue about? Pick up to 3 topics from the following list: {list(topic_maintainers_map.keys())} \nISSUE START:\n{issue['body']} \n ISSUE END. \n ANSWER:"
|
48 |
inputs = tokenizer(prompt, return_tensors="pt")
|
49 |
|
50 |
prefix_len = inputs.input_ids.shape[1]
|
update_stored_issues.py
CHANGED
@@ -35,7 +35,7 @@ TOKEN = os.environ.get("GITHUB_TOKEN")
|
|
35 |
JSON_FILE = f"issues.json"
|
36 |
|
37 |
|
38 |
-
def
|
39 |
input_filename=JSON_FILE,
|
40 |
output_filename=JSON_FILE,
|
41 |
github_api_version=GITHUB_API_VERSION,
|
@@ -151,4 +151,4 @@ if __name__ == "__main__":
|
|
151 |
parser.add_argument("--token", type=str, default=TOKEN)
|
152 |
parser.add_argument("--n_pages", type=int, default=-1)
|
153 |
args = parser.parse_args()
|
154 |
-
|
|
|
35 |
JSON_FILE = f"issues.json"
|
36 |
|
37 |
|
38 |
+
def update_issues(
|
39 |
input_filename=JSON_FILE,
|
40 |
output_filename=JSON_FILE,
|
41 |
github_api_version=GITHUB_API_VERSION,
|
|
|
151 |
parser.add_argument("--token", type=str, default=TOKEN)
|
152 |
parser.add_argument("--n_pages", type=int, default=-1)
|
153 |
args = parser.parse_args()
|
154 |
+
update_issues(**vars(args))
|