import os import gradio as gr from huggingface_hub import InferenceClient # Read Hugging Face token from Secrets HF_TOKEN = os.getenv("HF_TOKEN") client = InferenceClient( provider="hf-inference", api_key=HF_TOKEN, ) SYSTEM_PROMPT = """ You are an experienced Software QA Engineer. Generate a professional bug report in the following format: Bug Title: Severity: Priority: Module: Steps to Reproduce: Expected Result: Actual Result: Possible Root Cause: """ def generate_bug_report(description): try: response = client.chat.completions.create( model="Qwen/Qwen2.5-7B-Instruct", messages=[ { "role": "system", "content": SYSTEM_PROMPT }, { "role": "user", "content": description } ], max_tokens=500, ) return response.choices[0].message.content except Exception as e: return f"Error:\n\n{str(e)}" demo = gr.Interface( fn=generate_bug_report, inputs=gr.Textbox( lines=8, placeholder="Describe the software bug..." ), outputs=gr.Textbox(lines=20), title="🐞 AI Bug Report Generator", description="Enter a bug description and generate a professional QA bug report using AI." ) demo.launch()