clarity-ai 6.4.0 → 6.4.1
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/CHANGELOG.md +1 -1
- package/package.json +1 -1
- package/src/providers/index.js +5 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/providers/index.js
CHANGED
|
@@ -22,7 +22,9 @@ export async function* callAI(providerName, model, messages, options = {}) {
|
|
|
22
22
|
if (!provider) throw { type: 'config_error', message: 'Unknown provider: ' + providerName };
|
|
23
23
|
|
|
24
24
|
const key = getKey(providerName);
|
|
25
|
-
if (!key
|
|
25
|
+
if (!key && providerName !== 'huggingface') {
|
|
26
|
+
throw { type: 'auth_error', provider: providerName, message: 'No API key set for ' + providerName, hint: '/keys ' + providerName + ' <your-key>' };
|
|
27
|
+
}
|
|
26
28
|
|
|
27
29
|
const modelName = model.replace(/^[^/]+\//, '');
|
|
28
30
|
|
|
@@ -42,13 +44,13 @@ export async function* callAI(providerName, model, messages, options = {}) {
|
|
|
42
44
|
const extraHeaders = {};
|
|
43
45
|
if (providerName === 'huggingface') {
|
|
44
46
|
endpoint = provider.endpoint + '/' + modelName + '/v1/chat/completions';
|
|
45
|
-
extraHeaders['Authorization'] = 'Bearer ' + key;
|
|
47
|
+
if (key) extraHeaders['Authorization'] = 'Bearer ' + key;
|
|
46
48
|
} else if (providerName === 'openrouter') {
|
|
47
49
|
extraHeaders['HTTP-Referer'] = 'https://clarity-ai.local';
|
|
48
50
|
extraHeaders['X-Title'] = 'CLARITY AI';
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
const stream = streamResponse(endpoint, body, key, extraHeaders, options.signal);
|
|
53
|
+
const stream = streamResponse(endpoint, body, key || 'none', extraHeaders, options.signal);
|
|
52
54
|
for await (const event of stream) {
|
|
53
55
|
yield event;
|
|
54
56
|
}
|