Spaces:
Running
Running
File size: 1,379 Bytes
18a6da6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 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() |