Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Hugging Face Spaces app for Overworker - Gradio interface."""
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import asyncio
|
| 4 |
+
from main import analyze_repo, RepoRequest
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def analyze_repo_sync(url: str) -> dict:
|
| 8 |
+
"""Synchronous wrapper for async analyze_repo."""
|
| 9 |
+
try:
|
| 10 |
+
request = RepoRequest(url=url)
|
| 11 |
+
request.validate_github_url()
|
| 12 |
+
|
| 13 |
+
# Run async function in event loop
|
| 14 |
+
loop = asyncio.new_event_loop()
|
| 15 |
+
asyncio.set_event_loop(loop)
|
| 16 |
+
result = loop.run_until_complete(analyze_repo(request))
|
| 17 |
+
loop.close()
|
| 18 |
+
|
| 19 |
+
return result
|
| 20 |
+
except ValueError as e:
|
| 21 |
+
return {"error": str(e)}
|
| 22 |
+
except Exception as e:
|
| 23 |
+
return {"error": f"Analysis failed: {str(e)}"}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def format_result(result: dict) -> str:
|
| 27 |
+
"""Format analysis result for display."""
|
| 28 |
+
if "error" in result:
|
| 29 |
+
return f"❌ Error: {result['error']}"
|
| 30 |
+
|
| 31 |
+
lines = []
|
| 32 |
+
lines.append("# Overworker Analysis Results")
|
| 33 |
+
lines.append("")
|
| 34 |
+
lines.append(f"**Score:** {result['score']:.3f}/1.0")
|
| 35 |
+
lines.append(f"**Band:** {result['band']}")
|
| 36 |
+
lines.append(f"**Weakest Link:** {result['weakest_link']}")
|
| 37 |
+
lines.append("")
|
| 38 |
+
|
| 39 |
+
lines.append("## Component Scores")
|
| 40 |
+
for component, score in result['component_scores'].items():
|
| 41 |
+
lines.append(f"- **{component}:** {score:.2f}")
|
| 42 |
+
lines.append("")
|
| 43 |
+
|
| 44 |
+
lines.append("## KPI Report")
|
| 45 |
+
lines.append(f"**Overall Score:** {result['kpi_report']['overall_score']:.3f}")
|
| 46 |
+
lines.append("")
|
| 47 |
+
for kpi in result['kpi_report']['kpis']:
|
| 48 |
+
lines.append(f"- **{kpi['name']}:** {kpi['value']} {kpi['unit']}")
|
| 49 |
+
lines.append("")
|
| 50 |
+
|
| 51 |
+
lines.append("## E-Service Appraisal")
|
| 52 |
+
lines.append(f"**Total Endpoints:** {result['e_service_appraisal']['total_endpoints']}")
|
| 53 |
+
lines.append(f"**Total Value:** {result['e_service_appraisal']['total_value']:.3f}")
|
| 54 |
+
lines.append(f"**Liquidity Index:** {result['e_service_appraisal']['liquidity_index']:.3f}")
|
| 55 |
+
lines.append("")
|
| 56 |
+
|
| 57 |
+
lines.append("## Download Package")
|
| 58 |
+
lines.append(f"ZIP Filename: {result['filename']}")
|
| 59 |
+
lines.append("")
|
| 60 |
+
lines.append("Note: ZIP download available in web interface only")
|
| 61 |
+
|
| 62 |
+
return "\n".join(lines)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Create Gradio interface
|
| 66 |
+
with gr.Blocks(title="Overworker - GitHub Repo Verification") as demo:
|
| 67 |
+
gr.Markdown("# 🏗️ Overworker")
|
| 68 |
+
gr.Markdown("**AI execution layer - GitHub repo to verified package**")
|
| 69 |
+
gr.Markdown("")
|
| 70 |
+
|
| 71 |
+
with gr.Row():
|
| 72 |
+
url_input = gr.Textbox(
|
| 73 |
+
label="GitHub Repository URL",
|
| 74 |
+
placeholder="https://github.com/owner/repo",
|
| 75 |
+
value="https://github.com/overandor/overworker"
|
| 76 |
+
)
|
| 77 |
+
analyze_btn = gr.Button("Analyze", variant="primary")
|
| 78 |
+
|
| 79 |
+
with gr.Row():
|
| 80 |
+
result_output = gr.Markdown(label="Analysis Results")
|
| 81 |
+
|
| 82 |
+
with gr.Row():
|
| 83 |
+
zip_filename = gr.Textbox(label="ZIP Filename", interactive=False)
|
| 84 |
+
zip_download = gr.File(label="Download ZIP Package")
|
| 85 |
+
|
| 86 |
+
analyze_btn.click(
|
| 87 |
+
fn=lambda url: format_result(analyze_repo_sync(url)),
|
| 88 |
+
inputs=[url_input],
|
| 89 |
+
outputs=[result_output]
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
# Note: ZIP download not available in Gradio interface
|
| 93 |
+
# Users can use the main FastAPI app for full ZIP download functionality
|
| 94 |
+
|
| 95 |
+
gr.Markdown("---")
|
| 96 |
+
gr.Markdown("## About")
|
| 97 |
+
gr.Markdown("Overworker analyzes GitHub repositories and generates verification reports with:")
|
| 98 |
+
gr.Markdown("- **Overwork Score**: Commercialization readiness score")
|
| 99 |
+
gr.Markdown("- **Verification Firewall**: 10 quality gates")
|
| 100 |
+
gr.Markdown("- **Secret Scanner**: Detects sensitive data")
|
| 101 |
+
gr.Markdown("- **Claim Labeler**: Extracts and verifies README claims")
|
| 102 |
+
gr.Markdown("- **KPI Computation**: Heuristic performance metrics")
|
| 103 |
+
gr.Markdown("- **E-Service Appraisal**: Analyzes API endpoints")
|
| 104 |
+
gr.Markdown("- **Heuristic Derivatives**: Non-financial analytics")
|
| 105 |
+
gr.Markdown("")
|
| 106 |
+
gr.Markdown("**⚠️ Note:** This is a demonstration system. All financial metrics are heuristic analytics for codebase assessment only, not tradable instruments.")
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
if __name__ == "__main__":
|
| 110 |
+
demo.launch()
|