File size: 2,105 Bytes
4e06012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Startup Instructions for NPS-AI

This guide explains how to set up and run the NPS-AI project, including the FastAPI chatbot and the autonomous browser agent.

## Prerequisites

- **Python 3.10+**
- **Ollama** (for local agent inference)
- **Mistral API Key** (for chatbot RAG)

## 1. Environment Setup

1.  **Clone the repository** (if not already done).
2.  **Create a `.env` file** in the project root:
    ```bash
    cp .env.example .env  # If .env.example exists
    # OR create manually:
    touch .env
    ```
3.  **Configure Environment Variables** in `.env`:
    ```ini
    MISTRAL_API_KEY=your_mistral_api_key_here
    # Optional Admin Credentials for file management
    ADMIN_USERNAME=admin
    ADMIN_PASSWORD=admin
    ```

## 2. Install Dependencies

Install the required Python packages:

```bash
pip install -r requirements.txt
```

Verify that `playwright` browsers are installed (required for the agent):

```bash
playwright install
```

## 3. Ollama Setup (For Agent)

The agent uses a local Ollama model (`kimi-k2.5:cloud` by default in `nps_agent.py`). Ensure Ollama is running and the model is pulled:

1.  **Start Ollama**:
    ```bash
    ollama serve
    ```
2.  **Pull the Model**:
    ```bash
    ollama pull kimi-k2.5:cloud
    ```
    *(Note: If you use a different model, update `model_name` in `nps_agent.py`)*

## 4. Running the Application

### Option A: Run the Full Application (Chatbot + Agent API)

Start the FastAPI server:

```bash
python app.py
```

- **URL**: `http://localhost:7860`
- **Chatbot Interface**: Accessible at the root URL (configured via static files in `frontend`).
- **Agent Endpoint**: `POST /agent/run`

### Option B: Run the Agent Standalone

To test the agent directly specifically:

```bash
python nps_agent.py
```
*(This will prompt for a task input in the terminal)*

## Troubleshooting

- **Import Errors**: Ensure you are in the virtual environment (`source .venv/bin/activate` or similar).
- **Browser Issues**: Run `playwright install` again.
- **LLM Connection**: Check if Ollama is running on port 11434 (`http://localhost:11434`).