File size: 2,664 Bytes
781a94d
 
 
 
 
 
 
 
 
b85377a
41caa46
b85377a
41caa46
b85377a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41caa46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: SecurityChatbot
emoji: πŸ“š
colorFrom: gray
colorTo: pink
sdk: docker
pinned: false
---

# Security Awareness Chatbot πŸ”πŸ€–

A modular, AI-powered backend that simulates social engineering attacks and provides interactive quizzes to train users on cybersecurity best practicesβ€”all in a friendly **Egyptian Arabic** persona!

## 🌟 What Does This Bot Offer?

1. **πŸ›‘οΈ Interactive Security Assistant**
   Talk to a cybersecurity expert AI. Ask any question about digital safety, and get answers in simple, casual Egyptian Arabic.

2. **πŸ•΅οΈβ€β™‚οΈ Social Engineering Simulation (Roleplay)**
   Users can type `/train` to enter a simulated attack scenario. 
   - **Scenarios:** Bank employee, Delivery Courier, IT Support, WhatsApp Support, Lottery.
   - **Difficulty Levels:** Easy, Medium, Hard (ranging from obvious to highly manipulative).
   - **Mechanism:** The AI plays the attacker, trying to extract sensitive info. A separate AI (Evaluator) acts as a referee to catch if the user leaks data or successfully defends themselves for 4 turns.

3. **πŸ“ Dynamic Cybersecurity Quizzes**
   Users can choose the Quiz mode to get a dynamically generated Multiple Choice Question (MCQ) about cybersecurity topics. The bot evaluates their answer and provides a friendly explanation.

4. **⚑ High Reliability (Fallback Logic)**
   Powered by OpenAI (GPT-4o-mini) and Groq (Llama-3), with built-in automatic fallback to Google Gemini (1.5-flash) if the primary models experience downtime.

---

## πŸ“ Project Structure

```
securityChatbot/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ config.py
β”‚   β”‚   └── prompts.py
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── schemas.py
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── webhook.py
β”‚   └── services/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ llm_service.py
β”‚       └── state_manager.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ pyproject.toml
└── README.md
```

## Setup & Run Locally

```bash
uv sync
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```

## API Endpoints

| Method | Path       | Description                  |
|--------|------------|------------------------------|
| GET    | `/`        | Health check                 |
| POST   | `/webhook` | Main chat endpoint           |

### Webhook Payload

```json
{
  "user_id": "user123",
  "message": "Hello"
}
```

### Commands

- `/train` β€” Start the social engineering simulation