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.
@@ -49,25 +49,38 @@ module.exports = {
49
49
  try {
50
50
  const config = getConfig();
51
51
  const provider = params.provider || config.provider || 'openai';
52
- const model = params.model || config.model || 'gpt-4o';
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 === 'groq' || provider === 'together' || provider === 'openrouter') {
63
- // Yeni provider presetler için ana providerApiKey'i kullan
64
- apiKey = config.providerApiKey;
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.',
@@ -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
- const simpleCheckPrompt = {
132
- role: 'system',
133
- 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'
134
- };
135
- const simpleBody = { model, stream: false, messages: [simpleCheckPrompt, { role: 'user', content: task }], temperature: 0, max_tokens: 20 };
136
- let isSimple = false;
137
- try {
138
- const simpleResult = await apiCall(providerUrl, providerApiKey, simpleBody);
139
- const raw = (simpleResult.choices?.[0]?.message?.content || '').trim().toLowerCase().replace(/[^a-z]/g, '');
140
- isSimple = raw === 'simple';
141
- } catch {}
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