Spaces:
Build error
Build error
Commit ·
c802e8d
1
Parent(s): 86c4ec4
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,7 @@
|
|
| 1 |
-
import
|
| 2 |
from huggingface_hub import Repository
|
| 3 |
from github import Github
|
| 4 |
|
| 5 |
-
# Set up the Streamlit app
|
| 6 |
-
st.set_page_config(page_title="GitHub File Search", page_icon=":mag_right:")
|
| 7 |
-
|
| 8 |
# Define a function to get the 10 repositories with the largest file of the given name
|
| 9 |
def get_repositories_with_largest_file(filename):
|
| 10 |
# Search for the file on GitHub using the Hugging Face API
|
|
@@ -34,34 +31,19 @@ def get_repositories_with_largest_file(filename):
|
|
| 34 |
# Return the repository information
|
| 35 |
return repo_info
|
| 36 |
|
| 37 |
-
# Define the
|
| 38 |
-
def app():
|
| 39 |
-
#
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# Display the repository information
|
| 50 |
-
if repo_info:
|
| 51 |
-
st.write(f"Top 10 repositories with the largest {filename}:")
|
| 52 |
-
for index, repo in enumerate(repo_info):
|
| 53 |
-
st.write(f"{index+1}. [{repo['name']}]({repo['url']}) - {repo['size']} bytes")
|
| 54 |
-
st.write(f" {repo['description']}")
|
| 55 |
-
else:
|
| 56 |
-
st.warning(f"No repositories found with the file name {filename}.")
|
| 57 |
-
# Add a button to download the results as a text file
|
| 58 |
-
st.download_button(
|
| 59 |
-
label="Download results as text file",
|
| 60 |
-
data='\n\n'.join([f"{index+1}. {repo['name']} - {repo['size']} bytes\n{repo['url']}\n{repo['description']}" for index, repo in enumerate(repo_info)]),
|
| 61 |
-
file_name=f"GitHub File Search Results - {filename}.txt",
|
| 62 |
-
mime="text/plain"
|
| 63 |
-
)
|
| 64 |
|
| 65 |
-
# Run the
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from huggingface_hub import Repository
|
| 3 |
from github import Github
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
# Define a function to get the 10 repositories with the largest file of the given name
|
| 6 |
def get_repositories_with_largest_file(filename):
|
| 7 |
# Search for the file on GitHub using the Hugging Face API
|
|
|
|
| 31 |
# Return the repository information
|
| 32 |
return repo_info
|
| 33 |
|
| 34 |
+
# Define the Gradio app
|
| 35 |
+
def app(filename):
|
| 36 |
+
# Get the repositories with the largest file of the given name
|
| 37 |
+
repo_info = get_repositories_with_largest_file(filename)
|
| 38 |
+
# Display the repository information
|
| 39 |
+
if repo_info:
|
| 40 |
+
output = f"Top 10 repositories with the largest {filename}:\n"
|
| 41 |
+
for index, repo in enumerate(repo_info):
|
| 42 |
+
output += f"{index+1}. [{repo['name']}]({repo['url']}) - {repo['size']} bytes\n {repo['description']}\n"
|
| 43 |
+
else:
|
| 44 |
+
output = f"No repositories found with the file name {filename}."
|
| 45 |
+
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
# Run the Gradio app
|
| 48 |
+
iface = gr.Interface(fn=app, inputs="text", outputs="text", title="GitHub File Search")
|
| 49 |
+
iface.launch()
|