Spaces:
Running
Running
Delete files app.py requirements.txt with huggingface_hub
Browse files- app.py +0 -41
- requirements.txt +0 -2
app.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
# SPDX-License-Identifier: MIT
|
| 2 |
-
import json
|
| 3 |
-
from pathlib import Path
|
| 4 |
-
import gradio as gr
|
| 5 |
-
from graphrag_audit.communities import LeidenDetector
|
| 6 |
-
from graphrag_audit.eval import run_evaluation
|
| 7 |
-
from graphrag_audit.extract import extract_repository
|
| 8 |
-
from graphrag_audit.graph import KnowledgeGraph
|
| 9 |
-
from graphrag_audit.query import GraphRAG
|
| 10 |
-
from graphrag_audit.summarize import summarize_communities
|
| 11 |
-
|
| 12 |
-
ROOT = Path(__file__).resolve().parent / "sample_repo"
|
| 13 |
-
CORPUS = extract_repository(ROOT)
|
| 14 |
-
GRAPH = KnowledgeGraph().from_corpus(CORPUS)
|
| 15 |
-
HIERARCHY = LeidenDetector().detect(GRAPH)
|
| 16 |
-
REPORTS = summarize_communities(HIERARCHY, CORPUS)
|
| 17 |
-
RAG = GraphRAG(CORPUS, GRAPH, REPORTS)
|
| 18 |
-
METRICS = run_evaluation(str(ROOT), n=100)
|
| 19 |
-
|
| 20 |
-
def ask(question, mode):
|
| 21 |
-
result = RAG.query(question, mode=mode)
|
| 22 |
-
return json.dumps({
|
| 23 |
-
"answer": result.answer,
|
| 24 |
-
"citations": result.citations,
|
| 25 |
-
"communities": result.communities,
|
| 26 |
-
"method": HIERARCHY.method,
|
| 27 |
-
"communities_total": len(HIERARCHY.communities),
|
| 28 |
-
"eval": {"graph": METRICS["graph"], "flat": METRICS["flat"], "win_rate": METRICS["win_rate"]},
|
| 29 |
-
}, indent=2)
|
| 30 |
-
|
| 31 |
-
with gr.Blocks(title="GraphRAG CodeAudit Explorer") as demo:
|
| 32 |
-
gr.Markdown("# GraphRAG CodeAudit Explorer\nAsk a local or global question over the synthetic sample repository.")
|
| 33 |
-
question = gr.Textbox(label="Question", value="What security risks exist in auth.py?")
|
| 34 |
-
mode = gr.Radio(["global", "local"], value="global", label="Search mode")
|
| 35 |
-
button = gr.Button("Ask")
|
| 36 |
-
output = gr.Code(label="GraphRAG response", language="json")
|
| 37 |
-
button.click(ask, inputs=[question, mode], outputs=output)
|
| 38 |
-
demo.load(ask, inputs=[question, mode], outputs=output)
|
| 39 |
-
|
| 40 |
-
if __name__ == "__main__":
|
| 41 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
gradio>=5.0
|
| 2 |
-
git+https://github.com/itsoumya-d/GraphRAG-CodeAudit.git
|
|
|
|
|
|
|
|
|