Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
pipe = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
model="niranjan2777/cybersec-qwen",
|
| 8 |
tokenizer="niranjan2777/cybersec-qwen",
|
| 9 |
-
device_map="
|
|
|
|
| 10 |
)
|
| 11 |
|
| 12 |
-
|
| 13 |
def cybersec_assistant(user_input):
|
| 14 |
messages = [
|
| 15 |
{"role": "system", "content": "You are a cybersecurity expert. Give clear, structured answers."},
|
|
@@ -24,13 +25,13 @@ def cybersec_assistant(user_input):
|
|
| 24 |
|
| 25 |
return output[0]["generated_text"][-1]["content"]
|
| 26 |
|
| 27 |
-
|
| 28 |
iface = gr.Interface(
|
| 29 |
fn=cybersec_assistant,
|
| 30 |
inputs=gr.Textbox(lines=3, placeholder="Ask a cybersecurity question..."),
|
| 31 |
outputs="text",
|
| 32 |
-
title="
|
| 33 |
-
description="Ask anything about cybersecurity.
|
| 34 |
)
|
| 35 |
|
| 36 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
|
| 5 |
pipe = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
model="niranjan2777/cybersec-qwen",
|
| 8 |
tokenizer="niranjan2777/cybersec-qwen",
|
| 9 |
+
device_map="cpu",
|
| 10 |
+
torch_dtype="auto",
|
| 11 |
)
|
| 12 |
|
| 13 |
+
|
| 14 |
def cybersec_assistant(user_input):
|
| 15 |
messages = [
|
| 16 |
{"role": "system", "content": "You are a cybersecurity expert. Give clear, structured answers."},
|
|
|
|
| 25 |
|
| 26 |
return output[0]["generated_text"][-1]["content"]
|
| 27 |
|
| 28 |
+
|
| 29 |
iface = gr.Interface(
|
| 30 |
fn=cybersec_assistant,
|
| 31 |
inputs=gr.Textbox(lines=3, placeholder="Ask a cybersecurity question..."),
|
| 32 |
outputs="text",
|
| 33 |
+
title=" CyberSec Assistant_ Niranjan Labs",
|
| 34 |
+
description="Ask anything about cybersecurity.."
|
| 35 |
)
|
| 36 |
|
| 37 |
iface.launch()
|