Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,6 @@
|
|
1 |
-
import os
|
2 |
import gradio as gr
|
3 |
from repo_utils import extract_repo_content
|
4 |
|
5 |
-
# Get the HF token and space author name from environment variables
|
6 |
-
hf_token = os.getenv("HF_TOKEN")
|
7 |
-
hf_user = os.getenv("SPACE_AUTHOR_NAME")
|
8 |
-
|
9 |
-
if not hf_token:
|
10 |
-
raise ValueError("HF_TOKEN environment variable is not set")
|
11 |
-
if not hf_user:
|
12 |
-
raise ValueError("SPACE_AUTHOR_NAME environment variable is not set")
|
13 |
-
|
14 |
def format_output(extracted_content, repo_url):
|
15 |
formatted_output = f"# Repository URL: {repo_url}\n\n"
|
16 |
for file_data in extracted_content:
|
@@ -27,6 +17,8 @@ def format_output(extracted_content, repo_url):
|
|
27 |
return formatted_output
|
28 |
|
29 |
def extract_and_display(url):
|
|
|
|
|
30 |
extracted_content = extract_repo_content(url, hf_token, hf_user)
|
31 |
formatted_output = format_output(extracted_content, url)
|
32 |
return formatted_output
|
@@ -34,10 +26,8 @@ def extract_and_display(url):
|
|
34 |
app = gr.Blocks(theme="sudeepshouche/minimalist")
|
35 |
|
36 |
with app:
|
37 |
-
gr.Markdown("#
|
38 |
-
gr.
|
39 |
-
|
40 |
-
url_input = gr.Textbox(label="π Repository URL", placeholder="Enter the repository URL here OR select an example below...")
|
41 |
url_examples = gr.Examples(
|
42 |
examples=[
|
43 |
["https://huggingface.co/spaces/big-vision/paligemma-hf"],
|
@@ -47,9 +37,10 @@ with app:
|
|
47 |
],
|
48 |
inputs=url_input
|
49 |
)
|
50 |
-
output_display = gr.Textbox(label="
|
51 |
-
extract_button = gr.Button("
|
52 |
|
53 |
extract_button.click(fn=extract_and_display, inputs=url_input, outputs=output_display)
|
54 |
|
55 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from repo_utils import extract_repo_content
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
def format_output(extracted_content, repo_url):
|
5 |
formatted_output = f"# Repository URL: {repo_url}\n\n"
|
6 |
for file_data in extracted_content:
|
|
|
17 |
return formatted_output
|
18 |
|
19 |
def extract_and_display(url):
|
20 |
+
hf_token = os.getenv("HF_TOKEN")
|
21 |
+
hf_user = os.getenv("SPACE_AUTHOR_NAME")
|
22 |
extracted_content = extract_repo_content(url, hf_token, hf_user)
|
23 |
formatted_output = format_output(extracted_content, url)
|
24 |
return formatted_output
|
|
|
26 |
app = gr.Blocks(theme="sudeepshouche/minimalist")
|
27 |
|
28 |
with app:
|
29 |
+
gr.Markdown("# Hugging Face Space / Model Repository Content Extractor")
|
30 |
+
url_input = gr.Textbox(label="https:// URL of Repository", placeholder="Enter the repository URL here OR select an example below...")
|
|
|
|
|
31 |
url_examples = gr.Examples(
|
32 |
examples=[
|
33 |
["https://huggingface.co/spaces/big-vision/paligemma-hf"],
|
|
|
37 |
],
|
38 |
inputs=url_input
|
39 |
)
|
40 |
+
output_display = gr.Textbox(label="Extracted Repository Content", show_copy_button=True, lines=20, placeholder="Repository content will be extracted here...\n\nMetadata is captured for all files, but text content provided only for files less than 32 kb\n\n\n\nReview and search through the content here OR simply copy it for offline analysis!!. π€")
|
41 |
+
extract_button = gr.Button("Extract Content")
|
42 |
|
43 |
extract_button.click(fn=extract_and_display, inputs=url_input, outputs=output_display)
|
44 |
|
45 |
+
if __name__ == "__main__":
|
46 |
+
app.launch()
|