bimmo-cli 1.2.2 → 1.2.4
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/bin/bimmo +6 -3
- package/package.json +1 -1
- package/src/config.js +1 -3
- package/src/providers/openai.js +20 -9
package/bin/bimmo
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// Silencia o aviso de depreciação do punycode que polui o terminal em versões novas do Node
|
|
4
|
+
process.removeAllListeners('warning');
|
|
5
|
+
|
|
3
6
|
import { program } from 'commander';
|
|
4
7
|
import { startInteractive } from '../src/interface.js';
|
|
5
8
|
import { configure } from '../src/config.js';
|
|
@@ -7,13 +10,13 @@ import { configure } from '../src/config.js';
|
|
|
7
10
|
program
|
|
8
11
|
.name('bimmo')
|
|
9
12
|
.description('bimmo — Sua IA universal no terminal (verde & lavanda)')
|
|
10
|
-
.version('1.
|
|
13
|
+
.version('1.2.4');
|
|
11
14
|
|
|
12
15
|
program
|
|
13
16
|
.command('config')
|
|
14
17
|
.description('Configurar provedor e chave de API')
|
|
15
18
|
.action(configure);
|
|
16
19
|
|
|
17
|
-
program.action(startInteractive);
|
|
20
|
+
program.action(startInteractive);
|
|
18
21
|
|
|
19
|
-
program.parse();
|
|
22
|
+
program.parse();
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -10,7 +10,7 @@ const providers = {
|
|
|
10
10
|
grok: { baseURL: 'https://api.x.ai/v1', defaultModel: 'grok-2-1212' },
|
|
11
11
|
gemini: { baseURL: 'https://generativelanguage.googleapis.com/v1beta', defaultModel: 'gemini-2.0-flash' },
|
|
12
12
|
ollama: { baseURL: 'http://localhost:11434/api', defaultModel: 'llama3.2' },
|
|
13
|
-
openrouter: { baseURL: 'https://openrouter.ai/api/v1', defaultModel: 'google/gemini-2.0-flash-
|
|
13
|
+
openrouter: { baseURL: 'https://openrouter.ai/api/v1', defaultModel: 'google/gemini-2.0-flash-lite-preview-02-05:free' },
|
|
14
14
|
deepseek: { baseURL: 'https://api.deepseek.com', defaultModel: 'deepseek-chat' },
|
|
15
15
|
zai: { baseURL: 'https://api.z.ai/v1', defaultModel: 'glm-4' }
|
|
16
16
|
};
|
|
@@ -111,7 +111,6 @@ export async function configure() {
|
|
|
111
111
|
profiles[answers.profileName] = newProfile;
|
|
112
112
|
config.set('profiles', profiles);
|
|
113
113
|
|
|
114
|
-
// Define como ativo imediatamente
|
|
115
114
|
config.set('provider', newProfile.provider);
|
|
116
115
|
config.set('apiKey', newProfile.apiKey);
|
|
117
116
|
config.set('model', newProfile.model);
|
|
@@ -127,7 +126,6 @@ export function getConfig() {
|
|
|
127
126
|
|
|
128
127
|
export function updateActiveModel(newModel) {
|
|
129
128
|
config.set('model', newModel);
|
|
130
|
-
// Também atualiza no perfil se houver um ativo
|
|
131
129
|
const active = config.get('activeProfile');
|
|
132
130
|
if (active) {
|
|
133
131
|
const profiles = config.get('profiles');
|
package/src/providers/openai.js
CHANGED
|
@@ -5,9 +5,17 @@ import { tools } from '../agent.js';
|
|
|
5
5
|
export class OpenAIProvider extends BaseProvider {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
super(config);
|
|
8
|
+
|
|
9
|
+
const extraHeaders = {};
|
|
10
|
+
if (this.config.baseURL?.includes('openrouter.ai')) {
|
|
11
|
+
extraHeaders['HTTP-Referer'] = 'https://github.com/JudahAragao/bimmo-cli';
|
|
12
|
+
extraHeaders['X-Title'] = 'bimmo-cli';
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
this.client = new OpenAI({
|
|
9
16
|
apiKey: this.config.apiKey,
|
|
10
|
-
baseURL: this.config.baseURL
|
|
17
|
+
baseURL: this.config.baseURL,
|
|
18
|
+
defaultHeaders: extraHeaders
|
|
11
19
|
});
|
|
12
20
|
}
|
|
13
21
|
|
|
@@ -29,7 +37,6 @@ export class OpenAIProvider extends BaseProvider {
|
|
|
29
37
|
async sendMessage(messages) {
|
|
30
38
|
const formattedMessages = this.formatMessages(messages);
|
|
31
39
|
|
|
32
|
-
// Converte tools do agent.js para o formato da OpenAI
|
|
33
40
|
const openAiTools = tools.map(t => ({
|
|
34
41
|
type: 'function',
|
|
35
42
|
function: {
|
|
@@ -39,12 +46,19 @@ export class OpenAIProvider extends BaseProvider {
|
|
|
39
46
|
}
|
|
40
47
|
}));
|
|
41
48
|
|
|
42
|
-
const
|
|
49
|
+
const options = {
|
|
43
50
|
model: this.config.model,
|
|
44
51
|
messages: formattedMessages,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
temperature: 0.7
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Só envia tools se houver alguma definida para evitar erros em alguns provedores
|
|
56
|
+
if (openAiTools.length > 0) {
|
|
57
|
+
options.tools = openAiTools;
|
|
58
|
+
options.tool_choice = 'auto';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const response = await this.client.chat.completions.create(options);
|
|
48
62
|
|
|
49
63
|
const message = response.choices[0].message;
|
|
50
64
|
|
|
@@ -65,10 +79,7 @@ export class OpenAIProvider extends BaseProvider {
|
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
// Adiciona a chamada da tool e o resultado ao histórico
|
|
69
82
|
const nextMessages = [...formattedMessages, message, ...toolResults];
|
|
70
|
-
|
|
71
|
-
// Chamada recursiva para processar a resposta final da IA com o resultado da tool
|
|
72
83
|
return this.sendMessage(nextMessages);
|
|
73
84
|
}
|
|
74
85
|
|