Files changed (1) hide show
  1. app.py +0 -83
app.py DELETED
@@ -1,83 +0,0 @@
1
- import gradio as gr
2
- from huggingface_hub import hf_hub_download
3
- import json
4
- import gzip
5
-
6
-
7
- usernames = {}
8
-
9
-
10
- filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset", revision="v1.1")
11
- with gzip.open(filepath, 'r') as f:
12
- usernames["v1.1"] = json.loads(f.read().decode('utf-8'))
13
-
14
- filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset")
15
- with gzip.open(filepath, 'r') as f:
16
- usernames["v1.0"] = json.loads(f.read().decode('utf-8'))
17
-
18
- text = """\
19
- 🔍🌟AICodeFly⚡️ is a program to search github repos. The goal is to make repos easy to search, review, clone and download. AI to make your coding experience fast and easy.
20
- This search will match your term to find up to 100 github repositories that match your search. Use the link to shell the repository as html.
21
- """ + """\
22
- """
23
-
24
- def check_username(username, version):
25
- output_md = ""
26
- if username in usernames[version] and len(usernames[version][username])>0:
27
- repos = usernames[version][username]
28
- repo_word = "repository" if len(repos)==1 else "repositories"
29
- output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
30
- for repo in repos:
31
- output_md += f"_{repo}_\n\n"
32
- else:
33
- output_md += "**No**, your code is not in The Stack."
34
- return output_md.strip()
35
-
36
- def check_keyword(username, version):
37
- output_md = ""
38
- maxhitcount = 1000
39
- maxrepos = 70000000 #6M user entries * up to 18 per user
40
- currenthitcount=0
41
- currentrepos=0
42
- repocounter=0
43
- usercounter=0
44
-
45
- for repolist in usernames[version]:
46
- usercounter += 1
47
-
48
- #print(repolist)
49
- repos = usernames[version][repolist]
50
- repo_word = "repository" if len(repos)==1 else "repositories"
51
- #output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
52
- for repo in repos:
53
- repocounter += 1
54
- currentrepos += 1
55
- if currentrepos > maxrepos:
56
- output_md += f"**Found maximum repos**, Count: **{currentrepos}** in The Stack:\n\n"
57
- return output_md.strip()
58
- if username in repo:
59
- currenthitcount += 1
60
- output_md += f"_<a href=https://github.com/{repo} target=_blank>{repo} repocounter: {repocounter} usercounter: {usercounter}</a>_\n\n"
61
- if currenthitcount > maxhitcount:
62
- output_md += f"**Found maximum hits**, Count: **{currenthitcount}** in The Stack:\n\n"
63
- return output_md.strip()
64
- else:
65
- output_md += "**Searched All Repos**, Above found in The Stack."
66
- return output_md.strip()
67
-
68
- with gr.Blocks() as demo:
69
- with gr.Row():
70
- _, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
71
- with colum_2:
72
- gr.Markdown(text)
73
- version = gr.Dropdown(["v1.1", "v1.0"], label="The Stack version:", value="v1.1")
74
- username = gr.Text("", label="Keyword to match against repos e.g. BeatSaber")
75
- check_button = gr.Button("Check!")
76
-
77
- repos = gr.Markdown()
78
-
79
- #check_button.click(check_username, [username, version], repos)
80
- check_button.click(check_keyword, [username, version], repos)
81
-
82
-
83
- demo.launch()