import spaces import gradio as gr import time import threading import logging from gradio.themes.utils import sizes from main import run_repository_ranking # Import the repository ranking function # --------------------------- # Global Logging Buffer Setup # --------------------------- LOG_BUFFER = [] LOG_BUFFER_LOCK = threading.Lock() class BufferLogHandler(logging.Handler): def emit(self, record): log_entry = self.format(record) with LOG_BUFFER_LOCK: LOG_BUFFER.append(log_entry) root_logger = logging.getLogger() if not any(isinstance(h, BufferLogHandler) for h in root_logger.handlers): handler = BufferLogHandler() formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") handler.setFormatter(formatter) root_logger.addHandler(handler) def filter_logs(logs): filtered = [] last_was_fetching = False for log in logs: if "HTTP Request:" in log: if not last_was_fetching: filtered.append("Fetching repositories...") last_was_fetching = True else: filtered.append(log) last_was_fetching = False return filtered def parse_result_to_html(raw_result: str) -> str: """ Parses the raw string output from run_repository_ranking to an HTML table. Only the top 10 results are displayed. """ entries = raw_result.strip().split("Final Rank:") entries = entries[1:11] # Use only the first 10 entries if not entries: return "
No repositories found for your query.
" html = """Rank | Title | Link | Combined Score |
---|---|---|---|
{data.get('Final Rank', '')} | {data.get('Title', '')} | GitHub | {data.get('Combined Score', '')} |
Processing your request. Please wait...
" for status, details in stream_lite_workflow(topic): yield status, details # --------------------------- # App UI Setup Using Gradio Soft Theme with Centered Layout # --------------------------- with gr.Blocks( theme=gr.themes.Soft(text_size=sizes.text_md), title="DeepGit Lite", css=""" /* Center header and footer */ #header { text-align: center; margin-bottom: 20px; } #main-container { max-width: 800px; margin: auto; } #footer { text-align: center; margin-top: 20px; } """ ) as demo: gr.Markdown( """
✨ DeepGit Lite is the lightweight pro version of DeepGit.
It harnesses advanced deep semantic search to explore GitHub repositories and deliver curated results.
Under the hood, it leverages a hybrid ranking approach combining dense retrieval, BM25 scoring, and cross-encoder re-ranking for optimal discovery.
If the agent returns no repositories found, it means no chain was invoked due to GPU unavailability. Please duplicate the space and re-run.
🚀 Check out the full DeepGit version on GitHub and ⭐ Star DeepGit on GitHub!