Spaces:
Running
Running
| """Gradio app for Hugging Face Spaces deployment.""" | |
| from __future__ import annotations | |
| import json | |
| import gradio as gr | |
| from src.pipeline import CodingLLMPipeline | |
| pipeline = CodingLLMPipeline() | |
| def generate(instruction: str, user_input: str): | |
| try: | |
| result = pipeline.run(instruction, user_input) | |
| return json.dumps(result, indent=2) | |
| except Exception as exc: | |
| return json.dumps( | |
| { | |
| "code": "", | |
| "explanation": f"Generation failed: {exc}", | |
| "confidence": 0.0, | |
| "important_tokens": [], | |
| "relevancy_score": 0.0, | |
| "hallucination": True, | |
| "latency_ms": 0, | |
| }, | |
| indent=2, | |
| ) | |
| demo = gr.Interface( | |
| fn=generate, | |
| inputs=[ | |
| gr.Textbox(label="Instruction", placeholder="Explain, generate or debug code..."), | |
| gr.Textbox(label="Input", lines=12, placeholder="Paste code or context"), | |
| ], | |
| outputs=gr.Code(label="JSON Output", language="json"), | |
| title="Advanced Coding LLM", | |
| description="Fast coding assistant with confidence, relevancy, and hallucination checks.", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |