Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
|
|
|
| 5 |
model_path = hf_hub_download(
|
| 6 |
repo_id="bleondubos/CondorAI-7B",
|
| 7 |
filename="qwen2.5-coder-7b-instruct.Q4_K_M.gguf"
|
|
@@ -9,12 +10,9 @@ model_path = hf_hub_download(
|
|
| 9 |
|
| 10 |
llm = Llama(model_path=model_path, n_ctx=4096, n_threads=4)
|
| 11 |
|
| 12 |
-
# 2.
|
| 13 |
def predict(message, history):
|
| 14 |
-
# System prompt para definir la personalidad de la IA
|
| 15 |
system_prompt = "You are CondorAI, an expert AI in cybersecurity, SAST, and DAST. Provide technical, precise, and actionable security analysis."
|
| 16 |
-
|
| 17 |
-
# Construcción del prompt ChatML con el historial de la conversación
|
| 18 |
prompt = f"<|im_start|>system\n{system_prompt}<|im_end|>\n"
|
| 19 |
|
| 20 |
for user_msg, assistant_msg in history:
|
|
@@ -36,40 +34,19 @@ def predict(message, history):
|
|
| 36 |
partial_message += content
|
| 37 |
yield partial_message
|
| 38 |
|
| 39 |
-
with gr.Blocks() as demo:
|
| 40 |
-
gr.Markdown(
|
| 41 |
-
|
| 42 |
-
# 🦅 CondorAI Security Analyst
|
| 43 |
-
### Real-time SAST/DAST code auditing and vulnerability analysis.
|
| 44 |
-
"""
|
| 45 |
-
)
|
| 46 |
|
| 47 |
-
|
| 48 |
fn=predict,
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
height=600
|
| 53 |
-
),
|
| 54 |
-
textbox=gr.Textbox(
|
| 55 |
-
placeholder="Paste your code or ask a security question...",
|
| 56 |
-
container=False,
|
| 57 |
-
scale=7
|
| 58 |
-
),
|
| 59 |
-
submit_btn="Analyze",
|
| 60 |
-
stop_btn="Stop",
|
| 61 |
-
retry_btn="Retry",
|
| 62 |
-
undo_btn="Undo",
|
| 63 |
-
clear_btn="Clear Chat",
|
| 64 |
)
|
| 65 |
|
| 66 |
-
gr.Markdown(
|
| 67 |
-
|
| 68 |
-
---
|
| 69 |
-
**Note:** CondorAI uses Q4_K_M quantization to optimize performance on CPU.
|
| 70 |
-
License: CC BY-NC-SA 4.0.
|
| 71 |
-
"""
|
| 72 |
-
)
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
| 75 |
-
demo.launch(
|
|
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
from llama_cpp import Llama
|
| 4 |
|
| 5 |
+
# 1. Configuración del Modelo
|
| 6 |
model_path = hf_hub_download(
|
| 7 |
repo_id="bleondubos/CondorAI-7B",
|
| 8 |
filename="qwen2.5-coder-7b-instruct.Q4_K_M.gguf"
|
|
|
|
| 10 |
|
| 11 |
llm = Llama(model_path=model_path, n_ctx=4096, n_threads=4)
|
| 12 |
|
| 13 |
+
# 2. Función de Predicción
|
| 14 |
def predict(message, history):
|
|
|
|
| 15 |
system_prompt = "You are CondorAI, an expert AI in cybersecurity, SAST, and DAST. Provide technical, precise, and actionable security analysis."
|
|
|
|
|
|
|
| 16 |
prompt = f"<|im_start|>system\n{system_prompt}<|im_end|>\n"
|
| 17 |
|
| 18 |
for user_msg, assistant_msg in history:
|
|
|
|
| 34 |
partial_message += content
|
| 35 |
yield partial_message
|
| 36 |
|
| 37 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="emerald", neutral_hue="slate")) as demo:
|
| 38 |
+
gr.Markdown("# 🦅 CondorAI Security Analyst")
|
| 39 |
+
gr.Markdown("### Real-time SAST/DAST code auditing and vulnerability analysis.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
gr.ChatInterface(
|
| 42 |
fn=predict,
|
| 43 |
+
type="messages",
|
| 44 |
+
chatbot=gr.Chatbot(height=600),
|
| 45 |
+
textbox=gr.Textbox(placeholder="Paste your code or ask a security question...", scale=7),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
)
|
| 47 |
|
| 48 |
+
gr.Markdown("---")
|
| 49 |
+
gr.Markdown("**Note:** CondorAI uses Q4_K_M quantization. License: CC BY-NC-SA 4.0.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
+
demo.launch()
|