File size: 863 Bytes
940234e
3d2c222
 
5f80531
3d2c222
 
 
 
5f80531
 
3d2c222
940234e
5f80531
3d2c222
 
 
 
 
940234e
3d2c222
940234e
3d2c222
 
 
 
 
 
5f80531
3d2c222
 
 
 
5f80531
 
940234e
 
3d2c222
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
import gradio as gr
from transformers import pipeline


pipe = pipeline(
    "text-generation",
    model="niranjan2777/cybersec-qwen",
    tokenizer="niranjan2777/cybersec-qwen",
    device_map="cpu",
    torch_dtype="auto",
)


def cybersec_assistant(user_input):
    messages = [
        {"role": "system", "content": "You are a cybersecurity expert. Give clear, structured answers."},
        {"role": "user", "content": user_input},
    ]

    output = pipe(
        messages,
        max_new_tokens=200,
        temperature=0.7
    )

    return output[0]["generated_text"][-1]["content"]


iface = gr.Interface(
    fn=cybersec_assistant,
    inputs=gr.Textbox(lines=3, placeholder="Ask a cybersecurity question..."),
    outputs="text",
    title=" CyberSec Assistant_ Niranjan Labs",
    description="Ask anything about cybersecurity.."
)

iface.launch()