natureco-cli 5.20.3 → 5.20.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/README.md +2 -0
- package/bin/natureco.js +1 -1
- package/package.json +1 -1
- package/src/commands/chat.js +1 -0
- package/src/commands/help.js +2 -0
- package/src/commands/naturehub.js +98 -7
- package/src/commands/repl.js +1604 -1580
- package/src/tools/llm_task.js +20 -7
- package/src/tools/workflow.js +26 -11
- /package/src/tools/{http.js → http.js.bak} +0 -0
package/src/tools/llm_task.js
CHANGED
|
@@ -49,25 +49,38 @@ module.exports = {
|
|
|
49
49
|
try {
|
|
50
50
|
const config = getConfig();
|
|
51
51
|
const provider = params.provider || config.provider || 'openai';
|
|
52
|
-
|
|
52
|
+
let model = params.model || config.model || 'gpt-4o';
|
|
53
53
|
|
|
54
54
|
// LLM'ler sayıları string olarak dönebiliyor — cast et
|
|
55
55
|
const temperature = typeof params.temperature === 'string' ? parseFloat(params.temperature) : (params.temperature ?? 0.1);
|
|
56
56
|
const maxTokens = typeof params.maxTokens === 'string' ? parseInt(params.maxTokens, 10) : (params.maxTokens ?? 4096);
|
|
57
57
|
|
|
58
58
|
let apiKey;
|
|
59
|
-
if (provider === 'openai') apiKey = params.apiKey || config.openaiApiKey || process.env.OPENAI_API_KEY;
|
|
60
|
-
else if (provider === 'anthropic') apiKey = params.apiKey || config.anthropicApiKey || process.env.ANTHROPIC_API_KEY;
|
|
61
|
-
else if (provider === 'groq') apiKey = params.apiKey || config.groqApiKey || process.env.GROQ_API_KEY;
|
|
62
|
-
else if (provider === '
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
if (provider === 'openai') apiKey = params.apiKey || config.openaiApiKey || config.providerApiKey || process.env.OPENAI_API_KEY;
|
|
60
|
+
else if (provider === 'anthropic') apiKey = params.apiKey || config.anthropicApiKey || config.providerApiKey || process.env.ANTHROPIC_API_KEY;
|
|
61
|
+
else if (provider === 'groq') apiKey = params.apiKey || config.groqApiKey || config.providerApiKey || process.env.GROQ_API_KEY;
|
|
62
|
+
else if (provider === 'together' || provider === 'openrouter') {
|
|
63
|
+
apiKey = params.apiKey || config.providerApiKey;
|
|
64
|
+
} else {
|
|
65
|
+
apiKey = config.providerApiKey || params.apiKey;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
if (!apiKey) {
|
|
68
69
|
return { success: false, error: `API key required for ${provider}. Set: natureco config set ${provider}ApiKey <key> veya providerApiKey` };
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
// Provider URL ve model için config'deki varsayılanları kullan
|
|
73
|
+
if (config.providerUrl && provider === 'openai' && !params.provider) {
|
|
74
|
+
const url = config.providerUrl;
|
|
75
|
+
const isGM = url.includes('generativelanguage.googleapis.com') || url.includes('gemini');
|
|
76
|
+
if (isGM) {
|
|
77
|
+
baseUrl = url.replace(/\/+$/, '') + '/openai';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (config.providerModel && provider === 'openai' && !params.model) {
|
|
81
|
+
model = config.providerModel;
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
const systemPrompt = [
|
|
72
85
|
'You are a JSON-only function.',
|
|
73
86
|
'Return ONLY a valid JSON value.',
|
package/src/tools/workflow.js
CHANGED
|
@@ -128,17 +128,32 @@ async function workflow(params) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// Phase 0: Check if simple chat (passthrough) — no planning needed
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
// Önce heuristic kontrol (LLM çağrısı olmadan)
|
|
132
|
+
const simplePatterns = [
|
|
133
|
+
/^merhaba/i, /^selam/i, /^hey/i, /^hi/i, /^hello/i, /^iyi günler/i, /^günaydın/i,
|
|
134
|
+
/^iyi akşamlar/i, /^naber/i, /^nasılsın/i, /^nasilsin/i, /^ne var ne yok/i,
|
|
135
|
+
/^teşekkür/i, /^tesekkur/i, /^sağol/i, /^sagol/i, /^tamam/i, /^peki/i,
|
|
136
|
+
/^evet/i, /^hayır/i, /^hayir/i, /^olur/i, /^görüşürüz/i, /^görüşür/i,
|
|
137
|
+
/^bye/i, /^güle güle/i, /^kolay gelsin/i,
|
|
138
|
+
];
|
|
139
|
+
const taskTrimmed = (task || '').trim();
|
|
140
|
+
const isSimpleHeuristic = simplePatterns.some(p => p.test(taskTrimmed));
|
|
141
|
+
|
|
142
|
+
let isSimple = isSimpleHeuristic;
|
|
143
|
+
|
|
144
|
+
if (!isSimpleHeuristic) {
|
|
145
|
+
// Heuristic yetersizse LLM'e sor
|
|
146
|
+
const simpleCheckPrompt = {
|
|
147
|
+
role: 'system',
|
|
148
|
+
content: 'Gorevin basit bir selamlasma/sohbet mi yoksa arac gerektiren bir islem mi oldugunu belirle. Sadece "simple" veya "complex" yaz, kesinlikle baska bir sey yazma. Noktalama isareti koyma.\n\nSimple: selamlasma, nasilsin, bugun ne yaptin, havadan sudan, genel bilgi sorusu, ben kimim, adim ne, kullanici bilgisi sorgulama, hatirlatma talebi\nComplex: dosya islemleri, kod yazma, arastirma, karsilastirma, duzenleme, otomasyon, proje yonetimi, debug, internette arama gerektiren isler'
|
|
149
|
+
};
|
|
150
|
+
const simpleBody = { model, stream: false, messages: [simpleCheckPrompt, { role: 'user', content: task }], temperature: 0, max_tokens: 20 };
|
|
151
|
+
try {
|
|
152
|
+
const simpleResult = await apiCall(providerUrl, providerApiKey, simpleBody);
|
|
153
|
+
const raw = (simpleResult.choices?.[0]?.message?.content || '').trim().toLowerCase().replace(/[^a-z]/g, '');
|
|
154
|
+
isSimple = raw === 'simple';
|
|
155
|
+
} catch {}
|
|
156
|
+
}
|
|
142
157
|
|
|
143
158
|
if (isSimple) {
|
|
144
159
|
// Passthrough: just chat with LLM, no tools — include user memory
|
|
File without changes
|