caroushell 0.1.6 → 0.1.7
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-suggester.js +7 -2
- package/dist/hello-new-user.js +4 -4
- package/dist/test-generate.js +2 -0
- package/package.json +1 -1
package/dist/ai-suggester.js
CHANGED
|
@@ -41,6 +41,8 @@ async function generateContent(prompt, options) {
|
|
|
41
41
|
});
|
|
42
42
|
const res = await fetch(request.url, request.init);
|
|
43
43
|
if (!res.ok) {
|
|
44
|
+
const text = await res.text();
|
|
45
|
+
(0, logs_1.logLine)(`ai fetch error: ${res.statusText} (${text})`);
|
|
44
46
|
return "ai fetch error: " + res.statusText;
|
|
45
47
|
}
|
|
46
48
|
const out = await extractText(await res.json());
|
|
@@ -50,6 +52,7 @@ async function generateContent(prompt, options) {
|
|
|
50
52
|
return text;
|
|
51
53
|
}
|
|
52
54
|
catch (err) {
|
|
55
|
+
(0, logs_1.logLine)("ai caught error: " + err);
|
|
53
56
|
return "ai error: " + err.message;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -75,8 +78,10 @@ function buildRequest(args) {
|
|
|
75
78
|
headers: headers(args.apiKey),
|
|
76
79
|
body: JSON.stringify({
|
|
77
80
|
model: args.model,
|
|
78
|
-
temperature
|
|
79
|
-
|
|
81
|
+
// OpenAI does not support temperature on some models
|
|
82
|
+
// temperature: args.temperature,
|
|
83
|
+
// max_tokens: args.maxOutputTokens,
|
|
84
|
+
// max_completion_tokens: args.maxOutputTokens,
|
|
80
85
|
messages: [
|
|
81
86
|
{
|
|
82
87
|
role: "system",
|
package/dist/hello-new-user.js
CHANGED
|
@@ -87,24 +87,24 @@ async function runHelloNewUserFlow(configPath) {
|
|
|
87
87
|
apiKey = answer;
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
console.log("Please enter an API key
|
|
90
|
+
console.log("Please enter an API key. The value is stored in the local config file.");
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
const models = await (0, ai_suggester_1.listModels)(apiUrl, apiKey);
|
|
94
94
|
if (models.length > 0) {
|
|
95
|
-
console.log("Here are a few example model ids.");
|
|
95
|
+
console.log("Here are a few example model ids from your api service. Choose a fast and cheap model because AI suggestions happen as you type.");
|
|
96
96
|
for (const model of models.slice(0, 5)) {
|
|
97
97
|
console.log(` - ${model}`);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
let model = "";
|
|
101
101
|
while (!model) {
|
|
102
|
-
const answer = (await prompt("Model
|
|
102
|
+
const answer = (await prompt("Model id: ", rl)).trim();
|
|
103
103
|
if (answer) {
|
|
104
104
|
model = answer;
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
console.log("Please enter a model
|
|
107
|
+
console.log("Please enter a model id (example: google/gemini-2.5-flash-lite, mistralai/mistral-small-24b-instruct-2501).");
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
rl.close();
|
package/dist/test-generate.js
CHANGED
|
@@ -7,7 +7,9 @@ async function main() {
|
|
|
7
7
|
if (!config.apiKey) {
|
|
8
8
|
console.warn("Warning: no API key configured. The answer may be empty.");
|
|
9
9
|
}
|
|
10
|
+
console.log("Using apiUrl:", config.apiUrl);
|
|
10
11
|
const models = await (0, ai_suggester_1.listModels)(config.apiUrl || "", config.apiKey || "");
|
|
12
|
+
models.sort();
|
|
11
13
|
console.log("Available models:", models);
|
|
12
14
|
const question = "What is the capital of France?";
|
|
13
15
|
const answer = await (0, ai_suggester_1.generateContent)(question, {
|