zero-doc 1.0.14 → 1.0.15
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/dist/ai-analyzer.js +20 -4
- package/package.json +1 -1
package/dist/ai-analyzer.js
CHANGED
|
@@ -147,9 +147,9 @@ class AIAnalyzer {
|
|
|
147
147
|
if (!this.apiUrl) {
|
|
148
148
|
throw new Error('Proxy API URL not configured');
|
|
149
149
|
}
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
throw new Error(`Invalid API URL: "${
|
|
150
|
+
const baseUrl = this.apiUrl.trim();
|
|
151
|
+
if (!baseUrl.startsWith('http://') && !baseUrl.startsWith('https://')) {
|
|
152
|
+
throw new Error(`Invalid API URL: "${baseUrl}". URL must start with http:// or https://`);
|
|
153
153
|
}
|
|
154
154
|
try {
|
|
155
155
|
const headers = {
|
|
@@ -159,7 +159,23 @@ class AIAnalyzer {
|
|
|
159
159
|
if (this.token) {
|
|
160
160
|
headers['Authorization'] = `Bearer ${this.token}`;
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
// First, get the actual URL to use for the prompt request
|
|
163
|
+
const urlEndpoint = `${baseUrl}/url`;
|
|
164
|
+
const urlResponse = await fetch(urlEndpoint, {
|
|
165
|
+
method: 'GET',
|
|
166
|
+
headers,
|
|
167
|
+
});
|
|
168
|
+
if (!urlResponse.ok) {
|
|
169
|
+
const errorText = await urlResponse.text().catch(() => 'No error details');
|
|
170
|
+
throw new Error(`Failed to get API URL (${urlResponse.status}): ${urlResponse.statusText}. ${errorText}`);
|
|
171
|
+
}
|
|
172
|
+
const urlData = await urlResponse.json();
|
|
173
|
+
const actualUrl = urlData.url || urlData.endpoint || urlData.apiUrl;
|
|
174
|
+
if (!actualUrl || (typeof actualUrl !== 'string')) {
|
|
175
|
+
throw new Error('Invalid response from /url endpoint: missing or invalid URL');
|
|
176
|
+
}
|
|
177
|
+
// Now make the actual prompt request to the URL we got
|
|
178
|
+
const response = await fetch(actualUrl, {
|
|
163
179
|
method: 'POST',
|
|
164
180
|
headers,
|
|
165
181
|
body: JSON.stringify({ prompt }),
|