lwazi 1.6.7 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,187 +1,62 @@
1
- # Lwazi AI Assistant
1
+ # Lwazi
2
2
 
3
- [![npm version](https://badge.fury.io/js/lwazi-ai.svg)](https://badge.fury.io/js/lwazi-ai)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ AI assistant for Laravel applications.
5
4
 
6
- **AI-powered assistant for Laravel applications.** Add an intelligent chat widget to your Laravel app with just one command.
7
-
8
- ## Features
9
-
10
- - 🤖 **AI-Powered Chat**: Integrates with Ollama for local AI conversations
11
- - 🎨 **Customizable UI**: Modern chat widget with theme customization
12
- - 🔍 **Smart Navigation**: AI understands your app structure and helps users navigate
13
- - 📱 **Responsive Design**: Works on desktop and mobile
14
- - ⚡ **Easy Installation**: One-command setup for Laravel projects
15
- - 🔒 **Privacy-Focused**: Runs locally with Ollama, no external API calls
16
-
17
- ## Quick Start
18
-
19
- ### Prerequisites
20
-
21
- - **Laravel 10+** application
22
- - **PHP 8.1+**
23
- - **Node.js 14+** (for installation)
24
- - **Ollama** running locally
25
-
26
- ### Installation
5
+ ## Install
27
6
 
28
7
  ```bash
29
- # Install via npm
30
- npm install lwazi-ai
31
-
32
- # This will automatically run the post-install script
33
- # Then complete the installation by running:
34
- npx lwazi
8
+ npm install lwazi
9
+ npx lwazi install
35
10
  ```
36
11
 
37
- The installer will:
38
- - Download the latest Lwazi package
39
- - Configure your Laravel application
40
- - Set up environment variables
41
- - Publish necessary assets
42
- - Generate your site's knowledge base
43
-
44
- ### Manual Installation
12
+ ## Requirements
45
13
 
46
- If you prefer manual installation:
14
+ - Laravel 10+
15
+ - PHP 8.1+
16
+ - Ollama running locally
47
17
 
48
- ```bash
49
- # Clone the repository
50
- git clone https://github.com/nigelnkomo/lwazi.git
51
- cd your-laravel-project
18
+ ## Configure
52
19
 
53
- # Copy lwazi folder
54
- cp -r /path/to/lwazi/lwazi ./
20
+ Add to `.env`:
55
21
 
56
- # Run installation script
57
- ./lwazi/install
58
22
  ```
59
-
60
- ## Configuration
61
-
62
- After installation, configure these environment variables in your `.env` file:
63
-
64
- ```env
65
- # Lwazi AI Configuration
66
23
  LWAZI_OLLAMA_URL=http://localhost:11434
67
24
  LWAZI_MODEL=llama3.2:1b
68
- LWAZI_API_URL=/lwazi
69
- LWAZI_AUTO_INJECT=true
70
- LWAZI_POSITION=bottom-right
71
- LWAZI_THEME=blue
72
- LWAZI_ACCENT="#007aff"
73
- LWAZI_ACCENT_DARK="#0051d4"
74
25
  ```
75
26
 
76
27
  ## Usage
77
28
 
78
- Once installed, Lwazi will automatically appear as a chat widget in your Laravel application. Users can:
29
+ Lwazi adds a chat widget to your app automatically. Users can ask about your site and get AI-powered responses.
79
30
 
80
- - Ask questions about your website
81
- - Get navigation help
82
- - Interact with your content using AI
83
-
84
- ### Laravel Commands
31
+ ## Commands
85
32
 
86
33
  ```bash
87
- # Re-analyze your application structure
88
- php artisan lwazi:ingest
89
-
90
- # Run setup wizard
91
- php artisan lwazi:setup
92
-
93
- # Clear Lwazi cache
94
- php artisan lwazi:clear
34
+ php artisan lwazi:ingest # Re-analyze app structure
35
+ php artisan lwazi:clear # Clear cache
95
36
  ```
96
37
 
97
- ## How It Works
98
-
99
- Lwazi analyzes your Laravel application to understand:
100
-
101
- - **Routes & Navigation**: Maps your site's structure
102
- - **Content & Pages**: Indexes your views and content
103
- - **Database Schema**: Understands your data relationships
104
- - **Configuration**: Learns about your app's setup
105
-
106
- This knowledge allows the AI to provide contextual, helpful responses specific to your application.
107
-
108
38
  ## Customization
109
39
 
110
- ### Themes
111
-
112
- Lwazi supports multiple themes and custom colors. Configure via environment variables or publish the config:
40
+ Publish config to customize:
113
41
 
114
42
  ```bash
115
43
  php artisan vendor:publish --provider="Lwazi\Core\Providers\LwaziServiceProvider"
116
44
  ```
117
45
 
118
- ### Advanced Configuration
119
-
120
- Edit `config/lwazi.php` to customize:
46
+ Edit `config/lwazi.php` to change:
121
47
  - AI model settings
122
48
  - Widget appearance
123
49
  - Response behavior
124
- - Security settings
125
-
126
- ## Requirements
127
-
128
- - **Laravel**: 10.0, 11.0, or 12.0
129
- - **PHP**: 8.1 or higher
130
- - **Ollama**: Latest version
131
- - **Node.js**: 14+ (for installation only)
132
-
133
- ## Supported AI Models
134
-
135
- Lwazi works with any Ollama-compatible model:
136
-
137
- - **Llama 3.2**: `llama3.2:1b`, `llama3.2:3b`
138
- - **Llama 3**: `llama3:8b`, `llama3:70b`
139
- - **Mistral**: `mistral:7b`
140
- - **Phi-3**: `phi3:3.8b`
141
- - **Gemma**: `gemma:2b`, `gemma:7b`
142
50
 
143
51
  ## Troubleshooting
144
52
 
145
- ### Common Issues
146
-
147
- **"Ollama not available"**
148
- - Ensure Ollama is running: `ollama serve`
149
- - Check the URL in your `.env` file
150
-
151
- **"Model not found"**
152
- - Pull the model: `ollama pull llama3.2:1b`
153
- - Update `LWAZI_MODEL` in your `.env`
53
+ **Ollama not available**
54
+ - Run `ollama serve`
55
+ - Check `LWAZI_OLLAMA_URL` in `.env`
154
56
 
155
- **Widget not appearing**
156
- - Clear Laravel caches: `php artisan config:clear && php artisan cache:clear`
157
- - Check browser console for JavaScript errors
158
-
159
- ### Getting Help
160
-
161
- - 📖 **Documentation**: [GitHub Wiki](https://github.com/nigelnkomo/lwazi/wiki)
162
- - 🐛 **Issues**: [GitHub Issues](https://github.com/nigelnkomo/lwazi/issues)
163
- - 💬 **Discussions**: [GitHub Discussions](https://github.com/nigelnkomo/lwazi/discussions)
164
-
165
- ## Contributing
166
-
167
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
168
-
169
- 1. Fork the repository
170
- 2. Create a feature branch
171
- 3. Make your changes
172
- 4. Add tests if applicable
173
- 5. Submit a pull request
57
+ **Model not found**
58
+ - Run `ollama pull llama3.2:1b`
174
59
 
175
60
  ## License
176
61
 
177
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
178
-
179
- ## Credits
180
-
181
- - **Ollama**: For providing the local AI inference engine
182
- - **Laravel**: The PHP framework that makes this possible
183
- - **Open Source Community**: For the amazing tools and libraries
184
-
185
- ---
186
-
187
- **Made with ❤️ for the Laravel community**
62
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lwazi",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "description": "Lwazi is an AI assistant for Laravel. Install with one command to add an AI assistant to your Laravel app.",
5
5
  "main": "bin/lwazi.js",
6
6
  "bin": {
@@ -69,6 +69,16 @@ class AnalyzeProjectCommand extends Command
69
69
 
70
70
  $root = $this->extractRoot($rootUrl);
71
71
 
72
+ if (!isset($manifest['flat'])) {
73
+ $manifest['flat'] = [];
74
+ }
75
+ if (!isset($manifest['nodes'])) {
76
+ $manifest['nodes'] = [];
77
+ }
78
+ if (!isset($manifest['adjacency'])) {
79
+ $manifest['adjacency'] = [];
80
+ }
81
+
72
82
  foreach ($routes as $route) {
73
83
  $path = '/' . ltrim($route['uri'], '/');
74
84
 
@@ -149,6 +149,16 @@ class SetupCommand extends Command
149
149
 
150
150
  $root = $this->extractRoot($rootUrl);
151
151
 
152
+ if (!isset($manifest['flat'])) {
153
+ $manifest['flat'] = [];
154
+ }
155
+ if (!isset($manifest['nodes'])) {
156
+ $manifest['nodes'] = [];
157
+ }
158
+ if (!isset($manifest['adjacency'])) {
159
+ $manifest['adjacency'] = [];
160
+ }
161
+
152
162
  foreach ($routes as $route) {
153
163
  $path = '/' . ltrim($route['uri'], '/');
154
164
 
@@ -55,7 +55,7 @@ class ChatController extends Controller
55
55
  $ragService = app(RagService::class);
56
56
  $routes = $ragService->getRouteIndex();
57
57
 
58
- $prompt = "What is the single most important word (noun) this user is asking about? Just return the word, nothing else. Question: {$message}";
58
+ $prompt = "One word only. What does the user want to find? this user is asking about? Just return the word, nothing else. Question: {$message}";
59
59
 
60
60
  $terms = [];
61
61
  $llmError = null;
@@ -10,7 +10,7 @@ class GraphVisualizer
10
10
  $nodes = $manifest['nodes'] ?? [];
11
11
  $rootUrl = $manifest['root_url'] ?? '';
12
12
 
13
- if (empty($adjacency)) {
13
+ if (empty($adjacency) || empty($nodes)) {
14
14
  return "No graph data available.\n";
15
15
  }
16
16
 
@@ -43,7 +43,7 @@ class LwaziAgent
43
43
 
44
44
  public function isReady(): bool
45
45
  {
46
- return !empty($this->loadManifest()) && $this->isOllamaAvailable();
46
+ return $this->isOllamaAvailable();
47
47
  }
48
48
 
49
49
  protected function isOllamaAvailable(): bool
@@ -168,7 +168,7 @@ class LwaziService
168
168
  return null;
169
169
  }
170
170
 
171
- $prompt = "What is the single most important word (noun) this user is asking about? Just return the word, nothing else. Question: {$message}";
171
+ $prompt = "One word only. What does the user want to find? this user is asking about? Just return the word, nothing else. Question: {$message}";
172
172
 
173
173
  $response = $this->callOllama([
174
174
  ['role' => 'system', 'content' => 'Return only one word.'],
@@ -337,7 +337,7 @@ class LwaziService
337
337
  return null;
338
338
  }
339
339
 
340
- $prompt = "What is the single most important word (noun) this user is asking about? Just return the word, nothing else. Question: {$message}";
340
+ $prompt = "One word only. What does the user want to find? this user is asking about? Just return the word, nothing else. Question: {$message}";
341
341
 
342
342
  $response = $this->callOllama([
343
343
  ['role' => 'system', 'content' => 'Return only one word.'],