Spaces:
Running
on
Zero
Running
on
Zero
zamalali
commited on
Commit
·
5ab8b50
1
Parent(s):
ae13177
Refactor DeepGit Lite UI to enhance layout, improve user interaction, and provide immediate feedback during processing.
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import time
|
|
3 |
import threading
|
4 |
import logging
|
5 |
import spaces
|
6 |
-
from main import run_repository_ranking #
|
7 |
|
8 |
# ---------------------------
|
9 |
# Global Logging Buffer Setup
|
@@ -37,36 +37,8 @@ def filter_logs(logs):
|
|
37 |
last_was_fetching = False
|
38 |
return filtered
|
39 |
|
40 |
-
# ---------------------------
|
41 |
-
# Minimal Title, Favicon & Description
|
42 |
-
# ---------------------------
|
43 |
-
favicon_html = """
|
44 |
-
<head>
|
45 |
-
<link rel="icon" type="image/x-icon" href="file/assets/deepgit.ico">
|
46 |
-
<title>DeepGit Lite Research Agent</title>
|
47 |
-
</head>
|
48 |
-
"""
|
49 |
-
|
50 |
-
title = """
|
51 |
-
<div>
|
52 |
-
<h1>DeepGit Lite</h1>
|
53 |
-
<p>⚙️ A lightweight GitHub research agent for deep semantic search and ranking.</p>
|
54 |
-
</div>
|
55 |
-
"""
|
56 |
-
|
57 |
-
description = """
|
58 |
-
<p>
|
59 |
-
DeepGit Lite is a streamlined tool for semantic search on GitHub repositories. It retrieves repositories using dense retrieval, ranks them by similarity, and then presents the top results.
|
60 |
-
</p>
|
61 |
-
"""
|
62 |
-
|
63 |
-
footer = """
|
64 |
-
<div>
|
65 |
-
Made with ❤️ by <b>Zamal</b>
|
66 |
-
</div>
|
67 |
-
"""
|
68 |
-
|
69 |
def parse_result_to_html(raw_result: str) -> str:
|
|
|
70 |
entries = raw_result.strip().split("Final Rank:")
|
71 |
html = """
|
72 |
<table border="1" style="width:100%; border-collapse: collapse;">
|
@@ -136,32 +108,44 @@ def stream_lite_workflow(topic):
|
|
136 |
html_result = parse_result_to_html(raw_result)
|
137 |
yield "", html_result
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
# ---------------------------
|
140 |
-
# App UI Setup Using
|
141 |
# ---------------------------
|
142 |
-
with gr.Blocks() as demo:
|
143 |
-
gr.HTML(
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
run_button.click(
|
166 |
fn=lite_runner,
|
167 |
inputs=[research_input],
|
@@ -169,7 +153,7 @@ with gr.Blocks() as demo:
|
|
169 |
api_name="deepgit_lite",
|
170 |
show_progress=True
|
171 |
)
|
172 |
-
|
173 |
research_input.submit(
|
174 |
fn=lite_runner,
|
175 |
inputs=[research_input],
|
@@ -177,7 +161,13 @@ with gr.Blocks() as demo:
|
|
177 |
api_name="deepgit_lite_submit",
|
178 |
show_progress=True
|
179 |
)
|
180 |
-
|
181 |
-
gr.HTML(
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
demo.queue(max_size=10).launch()
|
|
|
3 |
import threading
|
4 |
import logging
|
5 |
import spaces
|
6 |
+
from main import run_repository_ranking # Your repository ranking function
|
7 |
|
8 |
# ---------------------------
|
9 |
# Global Logging Buffer Setup
|
|
|
37 |
last_was_fetching = False
|
38 |
return filtered
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
def parse_result_to_html(raw_result: str) -> str:
|
41 |
+
# Parses raw string output to an HTML table
|
42 |
entries = raw_result.strip().split("Final Rank:")
|
43 |
html = """
|
44 |
<table border="1" style="width:100%; border-collapse: collapse;">
|
|
|
108 |
html_result = parse_result_to_html(raw_result)
|
109 |
yield "", html_result
|
110 |
|
111 |
+
def lite_runner(topic):
|
112 |
+
# Provide immediate feedback upon button press.
|
113 |
+
yield "Workflow started", "<p>Processing your request. Please wait...</p>"
|
114 |
+
for status, details in stream_lite_workflow(topic):
|
115 |
+
yield status, details
|
116 |
+
|
117 |
# ---------------------------
|
118 |
+
# App UI Setup Using Gradio Soft Theme
|
119 |
# ---------------------------
|
120 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="DeepGit Lite", fill_width=True) as demo:
|
121 |
+
gr.HTML(
|
122 |
+
"""
|
123 |
+
<head>
|
124 |
+
<link rel="icon" type="image/x-icon" href="file/assets/deepgit.ico">
|
125 |
+
<title>DeepGit Lite Research Agent</title>
|
126 |
+
</head>
|
127 |
+
"""
|
128 |
+
)
|
129 |
+
gr.Markdown(
|
130 |
+
"""
|
131 |
+
# DeepGit Lite
|
132 |
+
Explore GitHub repositories with deep semantic search.
|
133 |
+
Check out our [GitHub](https://github.com/zamalali/DeepGit) for more details.
|
134 |
+
"""
|
135 |
+
)
|
136 |
+
|
137 |
+
with gr.Row():
|
138 |
+
with gr.Column(scale=2):
|
139 |
+
research_input = gr.Textbox(
|
140 |
+
label="Research Query",
|
141 |
+
placeholder="Enter your research topic here, e.g., 'data augmentation pipelines for LLM fine-tuning'",
|
142 |
+
lines=3
|
143 |
+
)
|
144 |
+
run_button = gr.Button("Run DeepGit Lite", variant="primary")
|
145 |
+
with gr.Column(scale=3):
|
146 |
+
status_display = gr.Markdown(label="Status")
|
147 |
+
detail_display = gr.HTML(label="Results")
|
148 |
+
|
149 |
run_button.click(
|
150 |
fn=lite_runner,
|
151 |
inputs=[research_input],
|
|
|
153 |
api_name="deepgit_lite",
|
154 |
show_progress=True
|
155 |
)
|
156 |
+
|
157 |
research_input.submit(
|
158 |
fn=lite_runner,
|
159 |
inputs=[research_input],
|
|
|
161 |
api_name="deepgit_lite_submit",
|
162 |
show_progress=True
|
163 |
)
|
164 |
+
|
165 |
+
gr.HTML(
|
166 |
+
"""
|
167 |
+
<div>
|
168 |
+
Made with ❤️ by <b>Zamal</b>
|
169 |
+
</div>
|
170 |
+
"""
|
171 |
+
)
|
172 |
|
173 |
demo.queue(max_size=10).launch()
|