update app.py
Browse files- README.md +2 -2
- app.py +45 -147
- awesome-ChatGPT-repositories.json +0 -0
- packages.txt +0 -1
- requirements.txt +1 -4
README.md
CHANGED
@@ -3,8 +3,8 @@ title: Awesome ChatGPT Repositories Search
|
|
3 |
emoji: π’
|
4 |
colorFrom: red
|
5 |
colorTo: blue
|
6 |
-
sdk:
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
3 |
emoji: π’
|
4 |
colorFrom: red
|
5 |
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.36.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
-
import difflib
|
2 |
import json
|
3 |
|
4 |
-
import
|
5 |
-
import
|
6 |
-
from pyserini.search.lucene import LuceneSearcher
|
7 |
|
8 |
|
9 |
def read_json(file_name):
|
@@ -12,146 +10,46 @@ def read_json(file_name):
|
|
12 |
return json_data
|
13 |
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
word1, word2, word3, word4, word5, word6 = st.columns(6)
|
59 |
-
with word1:
|
60 |
-
button1 = st.button("Prompt")
|
61 |
-
if button1:
|
62 |
-
self.query = "prompt"
|
63 |
-
|
64 |
-
with word2:
|
65 |
-
button2 = st.button("Chatbot")
|
66 |
-
if button2:
|
67 |
-
self.query = "chatbot"
|
68 |
-
|
69 |
-
with word3:
|
70 |
-
button3 = st.button("Langchain")
|
71 |
-
if button3:
|
72 |
-
self.query = "langchain"
|
73 |
-
|
74 |
-
with word4:
|
75 |
-
button4 = st.button("Extension")
|
76 |
-
if button4:
|
77 |
-
self.query = "extension"
|
78 |
-
|
79 |
-
with word5:
|
80 |
-
button5 = st.button("LLMs")
|
81 |
-
if button5:
|
82 |
-
self.query = "llms"
|
83 |
-
|
84 |
-
with word6:
|
85 |
-
button6 = st.button("API")
|
86 |
-
if button6:
|
87 |
-
self.query = "api"
|
88 |
-
|
89 |
-
def show_search_results(self):
|
90 |
-
if self.query or self.search_button:
|
91 |
-
st.write("#")
|
92 |
-
|
93 |
-
search_results = self.searcher.search(self.query, k=500)
|
94 |
-
num_search_results = len(search_results)
|
95 |
-
st.write(f"A total of {num_search_results} repositories found.")
|
96 |
-
|
97 |
-
if num_search_results > 0:
|
98 |
-
json_search_results = []
|
99 |
-
for result in search_results:
|
100 |
-
docid = result.docid
|
101 |
-
doc = self.searcher.doc(docid)
|
102 |
-
json_data = json.loads(doc.raw())
|
103 |
-
json_search_results.append(json_data)
|
104 |
-
|
105 |
-
for json_data in sorted(
|
106 |
-
json_search_results, key=lambda x: x["freq"], reverse=True
|
107 |
-
):
|
108 |
-
description = json_data["description"]
|
109 |
-
url = json_data["url"]
|
110 |
-
project_name = json_data["project_name"]
|
111 |
-
|
112 |
-
st.write("---")
|
113 |
-
st.subheader(f"[{project_name}]({url})")
|
114 |
-
st.write(description)
|
115 |
-
|
116 |
-
info = []
|
117 |
-
language = json_data["language"]
|
118 |
-
if language is not None and len(language) > 0:
|
119 |
-
info.append(language)
|
120 |
-
else:
|
121 |
-
info.append("Laugage: Unkwown")
|
122 |
-
|
123 |
-
license = json_data["license"]
|
124 |
-
if license is None:
|
125 |
-
info.append("License: Unkwown")
|
126 |
-
else:
|
127 |
-
info.append(license)
|
128 |
-
|
129 |
-
st.caption(" / ".join(info))
|
130 |
-
|
131 |
-
else:
|
132 |
-
if len(self.query) > 0:
|
133 |
-
scores = []
|
134 |
-
for candidate_word in self.candidate_words:
|
135 |
-
score = difflib.SequenceMatcher(
|
136 |
-
None, self.query, candidate_word
|
137 |
-
).ratio()
|
138 |
-
scores.append(score)
|
139 |
-
|
140 |
-
num_candidate_words = 6
|
141 |
-
|
142 |
-
indexes = np.argsort(scores)[::-1][:num_candidate_words]
|
143 |
-
suggestions = [self.candidate_words[i] for i in indexes]
|
144 |
-
suggestions = sorted(
|
145 |
-
set(suggestions), key=suggestions.index
|
146 |
-
)
|
147 |
-
st.caption("Suggestions")
|
148 |
-
for i, word in enumerate(suggestions, start=1):
|
149 |
-
st.write(f"{i}: {word}")
|
150 |
-
|
151 |
-
|
152 |
-
def main():
|
153 |
-
SearchApplication()
|
154 |
-
|
155 |
-
|
156 |
-
if __name__ == "__main__":
|
157 |
-
main()
|
|
|
|
|
1 |
import json
|
2 |
|
3 |
+
import gradio as gr
|
4 |
+
import pandas as pd
|
|
|
5 |
|
6 |
|
7 |
def read_json(file_name):
|
|
|
10 |
return json_data
|
11 |
|
12 |
|
13 |
+
data = {"project_name": [], "description": []}
|
14 |
+
|
15 |
+
json_file = "awesome-ChatGPT-repositories.json"
|
16 |
+
json_data = read_json(json_file)
|
17 |
+
for v in json_data["contents"].values():
|
18 |
+
for url, repo in v.items():
|
19 |
+
description = repo["multilingual_descriptions"]["en"]
|
20 |
+
project_name = repo["repository_name"]
|
21 |
+
data["project_name"].append(f"[{project_name}]({url})")
|
22 |
+
data["description"].append(description)
|
23 |
+
|
24 |
+
|
25 |
+
data = pd.DataFrame(data)
|
26 |
+
|
27 |
+
|
28 |
+
def show_search_results(queries):
|
29 |
+
queries = queries.lower()
|
30 |
+
queries = queries.split()
|
31 |
+
|
32 |
+
df_search = data
|
33 |
+
for query in queries:
|
34 |
+
contained_description = data["description"].str.contains(query)
|
35 |
+
contained_project_name = data["project_name"].str.contains(query)
|
36 |
+
df_search = df_search[contained_description | contained_project_name]
|
37 |
+
return df_search
|
38 |
+
|
39 |
+
|
40 |
+
with gr.Blocks() as demo:
|
41 |
+
gr.Markdown(
|
42 |
+
"""
|
43 |
+
# Awesome ChatGPT repositories search π
|
44 |
+
You can search for open-source software from [1500+ repositories](https://github.com/taishi-i/awesome-ChatGPT-repositories).
|
45 |
+
"""
|
46 |
+
)
|
47 |
+
|
48 |
+
query = gr.Textbox(label="Search words", placeholder="prompt")
|
49 |
+
df = gr.DataFrame(
|
50 |
+
value=data, type="pandas", datatype="markdown", height=1000
|
51 |
+
)
|
52 |
+
|
53 |
+
query.change(fn=show_search_results, inputs=query, outputs=df)
|
54 |
+
|
55 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
awesome-ChatGPT-repositories.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
packages.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
default-jdk
|
|
|
|
requirements.txt
CHANGED
@@ -1,4 +1 @@
|
|
1 |
-
|
2 |
-
faiss-cpu
|
3 |
-
torch
|
4 |
-
altair<5
|
|
|
1 |
+
pandas
|
|
|
|
|
|