lwazi 1.8.0 → 1.8.2
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/package.json
CHANGED
|
@@ -7,6 +7,9 @@ use Illuminate\Support\Facades\Artisan;
|
|
|
7
7
|
use Lwazi\Core\Installer\ProjectAnalyzer;
|
|
8
8
|
use Lwazi\Core\Installer\NavigationCrawler;
|
|
9
9
|
use Lwazi\Core\Services\GraphVisualizer;
|
|
10
|
+
use Illuminate\Support\Str;
|
|
11
|
+
use DOMDocument;
|
|
12
|
+
use DOMXPath;
|
|
10
13
|
|
|
11
14
|
class SetupCommand extends Command
|
|
12
15
|
{
|
|
@@ -63,6 +63,7 @@ class LwaziService
|
|
|
63
63
|
|
|
64
64
|
$intent = $this->selectIntentWithLLM($message);
|
|
65
65
|
error_log('Lwazi: intent = ' . ($intent ?? 'null'));
|
|
66
|
+
|
|
66
67
|
if ($intent === 'navigation') {
|
|
67
68
|
$nav = $this->findNavigationAnswer($message);
|
|
68
69
|
if ($nav) {
|
|
@@ -76,10 +77,20 @@ class LwaziService
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
$
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if ($intent === 'content' || $intent === 'navigation') {
|
|
81
|
+
$contentResponse = $this->searchContent($message);
|
|
82
|
+
if ($contentResponse) {
|
|
83
|
+
$this->conversationHistory[] = ['role' => 'assistant', 'content' => $contentResponse];
|
|
84
|
+
return $contentResponse;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if ($intent === 'navigation') {
|
|
89
|
+
$nav = $this->navigationFallbackWithLLM($message);
|
|
90
|
+
if ($nav) {
|
|
91
|
+
$this->conversationHistory[] = ['role' => 'assistant', 'content' => $nav];
|
|
92
|
+
return $nav;
|
|
93
|
+
}
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
$dataResponse = $this->fetchRelevantData($message);
|
|
@@ -107,7 +118,11 @@ class LwaziService
|
|
|
107
118
|
}
|
|
108
119
|
|
|
109
120
|
$prompt =
|
|
110
|
-
"Classify the user's intent as one of: navigation, data, general. Return JSON: {\"intent\":\"navigation|data|general\"}.\n\n" .
|
|
121
|
+
"Classify the user's intent as one of: navigation, content, data, general. Return JSON: {\"intent\":\"navigation|content|data|general\"}.\n\n" .
|
|
122
|
+
"- navigation: user wants to find a page or link\n" .
|
|
123
|
+
"- content: user is asking for information that might be on a page (not data)\n" .
|
|
124
|
+
"- data: user wants to query database records\n" .
|
|
125
|
+
"- general: casual conversation\n\n" .
|
|
111
126
|
"QUESTION:\n" .
|
|
112
127
|
$message;
|
|
113
128
|
|
|
@@ -119,7 +134,7 @@ class LwaziService
|
|
|
119
134
|
$json = $this->extractJson($response['content'] ?? '');
|
|
120
135
|
$intent = $json['intent'] ?? null;
|
|
121
136
|
|
|
122
|
-
if (in_array($intent, ['navigation', 'data', 'general'], true)) {
|
|
137
|
+
if (in_array($intent, ['navigation', 'content', 'data', 'general'], true)) {
|
|
123
138
|
return $intent;
|
|
124
139
|
}
|
|
125
140
|
|