n8n-nodes-zihin 0.1.0 → 0.3.0
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 +82 -186
- package/dist/nodes/ZihinChatModel/ZihinChatModel.node.d.ts +12 -0
- package/dist/nodes/ZihinChatModel/ZihinChatModel.node.js +636 -0
- package/dist/nodes/ZihinChatModel/ZihinChatModel.node.js.map +1 -0
- package/dist/nodes/ZihinChatModel/ZihinChatModel.node.json +22 -0
- package/dist/nodes/ZihinChatModel/zihin.png +0 -0
- package/dist/nodes/ZihinGateway/ZihinGateway.node.js +99 -11
- package/dist/nodes/ZihinGateway/ZihinGateway.node.js.map +1 -1
- package/dist/nodes/ZihinGateway/ZihinGateway.node.json +22 -0
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -3,25 +3,21 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/n8n-nodes-zihin)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
n8n
|
|
6
|
+
Nós n8n para integração com **Zihin LLM Gateway** - API unificada de LLMs com roteamento inteligente entre providers (OpenAI, Anthropic, Google, Grok e outros).
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Nós Disponíveis
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- **Acesso Unificado**: Uma única API para múltiplos providers (OpenAI, Anthropic, Google, Grok, OpenRouter)
|
|
15
|
-
- **Monitoramento**: Rastreamento de custos, uso e performance em tempo real
|
|
10
|
+
| Nó | Uso | Tool Calling |
|
|
11
|
+
|----|-----|--------------|
|
|
12
|
+
| **Zihin Gateway** | Workflows tradicionais | Não |
|
|
13
|
+
| **Zihin Chat Model** | AI Agents (LangChain) | Sim |
|
|
16
14
|
|
|
17
15
|
## Instalação
|
|
18
16
|
|
|
19
|
-
### Via n8n Community Nodes
|
|
17
|
+
### Via n8n Community Nodes (Recomendado)
|
|
20
18
|
|
|
21
|
-
1.
|
|
22
|
-
2.
|
|
23
|
-
3. Selecione **Install**
|
|
24
|
-
4. Digite `n8n-nodes-zihin` e clique em **Install**
|
|
19
|
+
1. **Settings** > **Community Nodes** > **Install**
|
|
20
|
+
2. Digite `n8n-nodes-zihin` e instale
|
|
25
21
|
|
|
26
22
|
### Via npm
|
|
27
23
|
|
|
@@ -29,210 +25,110 @@ Zihin é um gateway inteligente de LLMs que oferece:
|
|
|
29
25
|
npm install n8n-nodes-zihin
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
## Configuração
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
cd n8n-nodes-zihin
|
|
30
|
+
1. Obtenha sua API Key em [zihin.ai](https://console.zihin.ai) > **Settings** > **API Keys**
|
|
31
|
+
2. No n8n: **Credentials** > **Add Credential** > **Zihin API**
|
|
32
|
+
3. Cole sua API Key (formato: `zhn_live_xxx`)
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
npm install
|
|
34
|
+
---
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
npm run build
|
|
36
|
+
## Uso: Zihin Gateway
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
cd ~/.n8n/nodes
|
|
47
|
-
npm link /caminho/para/n8n-nodes-zihin
|
|
48
|
-
```
|
|
38
|
+
Para chamadas diretas em workflows tradicionais.
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
```
|
|
41
|
+
[Trigger] → [Zihin Gateway] → [Próximo nó]
|
|
42
|
+
```
|
|
51
43
|
|
|
52
|
-
|
|
44
|
+
1. Adicione o nó **Zihin Gateway**
|
|
45
|
+
2. Selecione um modelo ou use **Auto** para roteamento inteligente
|
|
46
|
+
3. Escolha **Prompt Simples** ou **Messages** (conversacional)
|
|
47
|
+
4. Execute
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
2. Navegue até **Settings** > **API Keys**
|
|
56
|
-
3. Crie uma nova API Key (formato: `zhn_live_xxx` ou `zhn_test_xxx`)
|
|
49
|
+
## Uso: Zihin Chat Model
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
Para AI Agents com suporte a ferramentas.
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
```
|
|
54
|
+
[Chat Trigger] → [AI Agent] ← [Zihin Chat Model]
|
|
55
|
+
↑
|
|
56
|
+
[Tools]
|
|
57
|
+
```
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
1. Adicione um nó **AI Agent**
|
|
60
|
+
2. Conecte **Zihin Chat Model** como Chat Model
|
|
61
|
+
3. Adicione **Tools** (Calculator, HTTP Request, etc.)
|
|
62
|
+
4. Conecte um trigger e execute
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
---
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
2. Selecione um modelo (ex: `OpenAI - GPT-4o`)
|
|
71
|
-
3. Escolha **Input Type**: `Prompt Simples`
|
|
72
|
-
4. Digite seu prompt
|
|
73
|
-
5. Execute o workflow
|
|
66
|
+
## Parâmetros
|
|
74
67
|
|
|
75
|
-
###
|
|
68
|
+
### Principais
|
|
76
69
|
|
|
77
|
-
|
|
70
|
+
| Parâmetro | Default | Descrição |
|
|
71
|
+
|-----------|---------|-----------|
|
|
72
|
+
| Model | - | Modelo LLM ou "Auto" para roteamento inteligente |
|
|
73
|
+
| Temperature | 0.7 | Criatividade (0-2) |
|
|
74
|
+
| Max Tokens | 4096 | Limite de tokens na resposta |
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
2. Escolha o **Task Type** que melhor descreve sua tarefa:
|
|
81
|
-
- `Chat / Conversação`: Conversas gerais
|
|
82
|
-
- `Coding / Programação`: Geração e análise de código
|
|
83
|
-
- `Analysis / Análise`: Análise de dados e documentos
|
|
84
|
-
- `Planning / Planejamento`: Planejamento e estratégia
|
|
85
|
-
- `Creative / Criativo`: Escrita criativa
|
|
86
|
-
- `Data Query / Consulta de Dados`: Consultas estruturadas
|
|
87
|
-
- `Tool Calling / Chamada de Ferramentas`: Uso de ferramentas/funções
|
|
88
|
-
3. Adicione suas mensagens no formato **Messages** (o modo Auto requer formato conversacional)
|
|
76
|
+
### Avançados (Ambos os Nós)
|
|
89
77
|
|
|
90
|
-
|
|
78
|
+
| Parâmetro | Default | Descrição |
|
|
79
|
+
|-----------|---------|-----------|
|
|
80
|
+
| Timeout | 60s | Tempo máximo de espera |
|
|
81
|
+
| Max Retries | 2 | Tentativas com backoff exponencial |
|
|
82
|
+
| Base URL Override | - | URL alternativa para testes locais |
|
|
91
83
|
|
|
92
|
-
|
|
84
|
+
### Exclusivo do Chat Model
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- `User`: Mensagens do usuário
|
|
98
|
-
- `Assistant`: Respostas anteriores do assistente
|
|
86
|
+
| Parâmetro | Default | Descrição |
|
|
87
|
+
|-----------|---------|-----------|
|
|
88
|
+
| Max Context Messages | 0 | Limite de mensagens (0 = sem limite) |
|
|
99
89
|
|
|
100
|
-
|
|
90
|
+
---
|
|
101
91
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| Parâmetro | Tipo | Obrigatório | Descrição |
|
|
105
|
-
|-----------|------|-------------|-----------|
|
|
106
|
-
| Model | options | Sim | Modelo LLM ou "auto" para roteamento inteligente |
|
|
107
|
-
| Task Type | options | Não | Tipo de tarefa (apenas quando model="auto") |
|
|
108
|
-
| Input Type | options | Sim | "Prompt Simples" ou "Messages" (Auto requer Messages) |
|
|
109
|
-
| Prompt | string | Condicional | Texto do prompt (quando Input Type = "Prompt Simples") |
|
|
110
|
-
| Messages | collection | Condicional | Lista de mensagens (quando Input Type = "Messages") |
|
|
111
|
-
|
|
112
|
-
### Options (Avançado)
|
|
113
|
-
|
|
114
|
-
| Parâmetro | Tipo | Default | Descrição |
|
|
115
|
-
|-----------|------|---------|-----------|
|
|
116
|
-
| Temperature | number | 0.7 | Criatividade (0-2) |
|
|
117
|
-
| Max Tokens | number | 1000 | Limite de tokens na resposta |
|
|
118
|
-
| Top P | number | 1 | Nucleus sampling (0-1) |
|
|
119
|
-
| Frequency Penalty | number | 0 | Reduz repetição (-2 a 2) |
|
|
120
|
-
| Presence Penalty | number | 0 | Incentiva novos tópicos (-2 a 2) |
|
|
121
|
-
| Stop Sequences | string | - | Sequências de parada (vírgula-separadas) |
|
|
122
|
-
| Session ID | string | - | ID para manter contexto entre chamadas |
|
|
123
|
-
|
|
124
|
-
## Modelos Disponíveis
|
|
125
|
-
|
|
126
|
-
### OpenAI
|
|
127
|
-
- GPT-5 (`openai.gpt-5`)
|
|
128
|
-
- GPT-5 Mini (`openai.gpt-5-mini`)
|
|
129
|
-
- GPT-5 Nano (`openai.gpt-5-nano`)
|
|
130
|
-
- GPT-4.1 (`openai.gpt-4.1`)
|
|
131
|
-
- GPT-4.1 Mini (`openai.gpt-4.1-mini`)
|
|
132
|
-
- GPT-4.1 Nano (`openai.gpt-4.1-nano`)
|
|
133
|
-
|
|
134
|
-
### Anthropic
|
|
135
|
-
- Claude Sonnet 4.5 (`anthropic.claude-sonnet-4-5-20250929`)
|
|
136
|
-
- Claude Haiku 4.5 (`anthropic.claude-haiku-4-5-20251001`)
|
|
137
|
-
- Claude Opus 4.1 (`anthropic.claude-opus-4-1-20250805`)
|
|
138
|
-
- Claude Sonnet 4 (`anthropic.claude-sonnet-4-20250514`)
|
|
139
|
-
- Claude 3.5 Haiku (`anthropic.claude-3-5-haiku-20241022`)
|
|
140
|
-
|
|
141
|
-
### Google
|
|
142
|
-
- Gemini 2.5 Flash Lite (`google.gemini-2.5-flash-lite`)
|
|
143
|
-
- Gemini 2.0 Flash (`google.gemini-2.0-flash`)
|
|
144
|
-
- Gemini 2.0 Flash Lite (`google.gemini-2.0-flash-lite`)
|
|
145
|
-
|
|
146
|
-
### Grok
|
|
147
|
-
- Grok 4 Fast Reasoning (`grok.grok-4-fast-reasoning`)
|
|
148
|
-
- Grok 4 Fast (`grok.grok-4-fast-non-reasoning`)
|
|
149
|
-
- Grok 4 (`grok.grok-4-0709`)
|
|
150
|
-
- Grok Code Fast (`grok.grok-code-fast-1`)
|
|
151
|
-
- Grok 3 (`grok.grok-3`)
|
|
152
|
-
- Grok 3 Mini (`grok.grok-3-mini`)
|
|
153
|
-
- Grok 2 (`grok.grok-2-1212`)
|
|
154
|
-
- Grok 2 Vision (`grok.grok-2-vision-1212`)
|
|
155
|
-
|
|
156
|
-
## Output
|
|
157
|
-
|
|
158
|
-
O nó retorna um objeto JSON com a seguinte estrutura:
|
|
159
|
-
|
|
160
|
-
```json
|
|
161
|
-
{
|
|
162
|
-
"content": "Resposta do modelo...",
|
|
163
|
-
"model": "gpt-4.1-mini",
|
|
164
|
-
"provider": "openai",
|
|
165
|
-
"threadId": null,
|
|
166
|
-
"finishReason": "stop",
|
|
167
|
-
"usage": {
|
|
168
|
-
"prompt_tokens": 50,
|
|
169
|
-
"completion_tokens": 100,
|
|
170
|
-
"total_tokens": 150,
|
|
171
|
-
"cached_tokens": 0
|
|
172
|
-
},
|
|
173
|
-
"cost": {
|
|
174
|
-
"input_cost_usd": 0.00025,
|
|
175
|
-
"output_cost_usd": 0.0015,
|
|
176
|
-
"total_cost_usd": 0.00175
|
|
177
|
-
},
|
|
178
|
-
"cached": false,
|
|
179
|
-
"requestId": "req_abc123",
|
|
180
|
-
"executionTimeMs": 1234,
|
|
181
|
-
"autoRouting": null
|
|
182
|
-
}
|
|
183
|
-
```
|
|
92
|
+
## Modelos Suportados
|
|
184
93
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"autoRouting": {
|
|
190
|
-
"originalModel": "auto",
|
|
191
|
-
"selectedModel": "openai.gpt-4o",
|
|
192
|
-
"confidence": 0.95,
|
|
193
|
-
"reasoning": "Task requires coding capabilities..."
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
94
|
+
- **OpenAI**: GPT-5, GPT-4.1, GPT-4.1-mini
|
|
95
|
+
- **Anthropic**: Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4.1
|
|
96
|
+
- **Google**: Gemini 2.5 Flash, Gemini 2.0 Flash
|
|
97
|
+
- **Grok**: Grok 4, Grok 3, Grok Code
|
|
197
98
|
|
|
198
|
-
|
|
99
|
+
Use **Auto** para roteamento automático baseado no tipo de tarefa.
|
|
199
100
|
|
|
200
|
-
|
|
201
|
-
- Verifique se a API Key está correta
|
|
202
|
-
- Confirme que a key não expirou no dashboard do Zihin
|
|
203
|
-
- Teste a key diretamente na API
|
|
101
|
+
---
|
|
204
102
|
|
|
205
|
-
|
|
206
|
-
- Aguarde o tempo indicado na mensagem
|
|
207
|
-
- Considere upgrade do plano no Zihin
|
|
208
|
-
- Implemente retry com backoff no workflow
|
|
103
|
+
## Troubleshooting
|
|
209
104
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
105
|
+
| Erro | Solução |
|
|
106
|
+
|------|---------|
|
|
107
|
+
| "Tools Agent requires Chat Model..." | Use **Zihin Chat Model**, não Gateway |
|
|
108
|
+
| "API Key inválida" | Verifique a key no dashboard Zihin |
|
|
109
|
+
| "Timeout após Xms" | Aumente o timeout em Options |
|
|
110
|
+
| "Rate limit" | Aguarde ou faça upgrade do plano |
|
|
213
111
|
|
|
214
|
-
|
|
215
|
-
- Verifique sua conexão com a internet
|
|
216
|
-
- Confirme que `llm.zihin.ai` está acessível
|
|
217
|
-
- Verifique firewall/proxy da sua rede
|
|
112
|
+
---
|
|
218
113
|
|
|
219
|
-
##
|
|
114
|
+
## Changelog
|
|
220
115
|
|
|
221
|
-
|
|
222
|
-
-
|
|
223
|
-
-
|
|
224
|
-
-
|
|
116
|
+
### v0.3.0 (2025-12-16)
|
|
117
|
+
- **Ambos os nós**: Timeout, Max Retries com backoff, Base URL Override
|
|
118
|
+
- **Chat Model**: Max Context Messages para proteção de custos
|
|
119
|
+
- Telemetria com call_source dinâmico
|
|
225
120
|
|
|
226
|
-
|
|
121
|
+
### v0.2.0 (2024-12-05)
|
|
122
|
+
- Zihin Chat Model para AI Agents com Tool Calling
|
|
227
123
|
|
|
228
|
-
|
|
229
|
-
-
|
|
230
|
-
- **Documentação**: [docs.zihin.ai](https://docs.zihin.ai)
|
|
124
|
+
### v0.1.0
|
|
125
|
+
- Release inicial com Zihin Gateway
|
|
231
126
|
|
|
232
|
-
|
|
127
|
+
---
|
|
233
128
|
|
|
234
|
-
|
|
129
|
+
## Links
|
|
235
130
|
|
|
236
|
-
|
|
131
|
+
- [Documentação Zihin](https://docs.zihin.ai)
|
|
132
|
+
- [Dashboard](https://console.zihin.ai/admin/home)
|
|
237
133
|
|
|
238
|
-
Desenvolvido por [
|
|
134
|
+
**Licença**: MIT | Desenvolvido por [Zihin AI Inc](https://zihin.ai)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { INodeType, INodeTypeDescription, ISupplyDataFunctions, SupplyData } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* n8n Node: Zihin Chat Model
|
|
4
|
+
* Sub-node for AI Agents that provides Zihin LLM as a chat model with Tool Calling support
|
|
5
|
+
*/
|
|
6
|
+
export declare class ZihinChatModel implements INodeType {
|
|
7
|
+
description: INodeTypeDescription;
|
|
8
|
+
/**
|
|
9
|
+
* Supply the LangChain chat model to the AI Agent
|
|
10
|
+
*/
|
|
11
|
+
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZihinChatModel = void 0;
|
|
4
|
+
// String literal for AI Language Model connection type
|
|
5
|
+
const AI_LANGUAGE_MODEL_OUTPUT = 'ai_languageModel';
|
|
6
|
+
const chat_models_1 = require("@langchain/core/language_models/chat_models");
|
|
7
|
+
const messages_1 = require("@langchain/core/messages");
|
|
8
|
+
/**
|
|
9
|
+
* Zihin Chat Model - LangChain compatible chat model for n8n AI Agents
|
|
10
|
+
* Supports Tool Calling for AI Agent integration
|
|
11
|
+
*/
|
|
12
|
+
class ZihinLangChainChatModel extends chat_models_1.BaseChatModel {
|
|
13
|
+
static lc_name() {
|
|
14
|
+
return 'ZihinChatModel';
|
|
15
|
+
}
|
|
16
|
+
get lc_secrets() {
|
|
17
|
+
return {
|
|
18
|
+
apiKey: 'ZIHIN_API_KEY',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
constructor(fields) {
|
|
22
|
+
super({});
|
|
23
|
+
this.boundTools = [];
|
|
24
|
+
this.apiKey = fields.apiKey;
|
|
25
|
+
this.modelName = fields.modelName;
|
|
26
|
+
this.taskType = fields.taskType || 'tool_calling';
|
|
27
|
+
this.temperature = fields.temperature ?? 0.7;
|
|
28
|
+
this.maxTokens = fields.maxTokens ?? 4096;
|
|
29
|
+
this.topP = fields.topP ?? 1;
|
|
30
|
+
this.frequencyPenalty = fields.frequencyPenalty ?? 0;
|
|
31
|
+
this.presencePenalty = fields.presencePenalty ?? 0;
|
|
32
|
+
// Novos campos - Alta Prioridade
|
|
33
|
+
this.timeout = fields.timeout ?? 60000;
|
|
34
|
+
this.maxRetries = fields.maxRetries ?? 2;
|
|
35
|
+
this.baseUrl = fields.baseUrl || 'https://llm.zihin.ai';
|
|
36
|
+
// Novos campos - Média Prioridade
|
|
37
|
+
this.maxContextMessages = fields.maxContextMessages ?? 0;
|
|
38
|
+
// Novos campos - Baixa Prioridade
|
|
39
|
+
this.stop = fields.stop ? fields.stop.split(',').map((s) => s.trim()) : [];
|
|
40
|
+
this.sessionId = fields.sessionId ?? '';
|
|
41
|
+
// Contexto para call_source dinâmico
|
|
42
|
+
this.callSourceContext = fields.callSourceContext ?? {};
|
|
43
|
+
}
|
|
44
|
+
_llmType() {
|
|
45
|
+
return 'zihin';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Constrói o call_source dinâmico com contexto do workflow/node/execution
|
|
49
|
+
* Formato: n8n_chat_model.{workflow_id}.{node_name}.{execution_id}
|
|
50
|
+
*/
|
|
51
|
+
buildCallSource() {
|
|
52
|
+
const parts = ['n8n_chat_model'];
|
|
53
|
+
if (this.callSourceContext.workflowId) {
|
|
54
|
+
parts.push(this.callSourceContext.workflowId);
|
|
55
|
+
}
|
|
56
|
+
if (this.callSourceContext.nodeName) {
|
|
57
|
+
// Sanitiza o nome do node (remove espaços e caracteres especiais)
|
|
58
|
+
const sanitizedNodeName = this.callSourceContext.nodeName
|
|
59
|
+
.replace(/[^a-zA-Z0-9_-]/g, '_')
|
|
60
|
+
.substring(0, 50);
|
|
61
|
+
parts.push(sanitizedNodeName);
|
|
62
|
+
}
|
|
63
|
+
if (this.callSourceContext.executionId) {
|
|
64
|
+
parts.push(this.callSourceContext.executionId);
|
|
65
|
+
}
|
|
66
|
+
return parts.join('.');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Helper para delay (usado no retry)
|
|
70
|
+
*/
|
|
71
|
+
async _delay(ms) {
|
|
72
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Executa chamada HTTP com timeout e retry com exponential backoff
|
|
76
|
+
*/
|
|
77
|
+
async _callWithRetry(requestBody) {
|
|
78
|
+
let lastError = null;
|
|
79
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
80
|
+
try {
|
|
81
|
+
const controller = new AbortController();
|
|
82
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
83
|
+
const response = await fetch(this.baseUrl + '/api/v3/llm/public/call', {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
'X-Api-Key': this.apiKey,
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify(requestBody),
|
|
90
|
+
signal: controller.signal,
|
|
91
|
+
});
|
|
92
|
+
clearTimeout(timeoutId);
|
|
93
|
+
// Retry apenas em erros 5xx ou rate limit (429)
|
|
94
|
+
if (response.status >= 500 || response.status === 429) {
|
|
95
|
+
throw new Error(`HTTP ${response.status}`);
|
|
96
|
+
}
|
|
97
|
+
return response;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
lastError = error;
|
|
101
|
+
// Timeout - não faz retry, lança imediatamente
|
|
102
|
+
if (error.name === 'AbortError') {
|
|
103
|
+
throw new Error(`Zihin API timeout após ${this.timeout}ms`);
|
|
104
|
+
}
|
|
105
|
+
// Retry com exponential backoff
|
|
106
|
+
if (attempt < this.maxRetries) {
|
|
107
|
+
const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
|
|
108
|
+
console.warn(`⚠️ Zihin API retry ${attempt + 1}/${this.maxRetries} após ${delay}ms`);
|
|
109
|
+
await this._delay(delay);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
throw lastError || new Error('Max retries exceeded');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Convert a schema to JSON Schema format
|
|
117
|
+
*/
|
|
118
|
+
schemaToJsonSchema(schema) {
|
|
119
|
+
if (!schema)
|
|
120
|
+
return {};
|
|
121
|
+
// If it's already a plain object (JSON Schema), return it
|
|
122
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
123
|
+
// Check if it's a Zod schema (has _def property)
|
|
124
|
+
if ('_def' in schema) {
|
|
125
|
+
// Try to get the JSON schema if available
|
|
126
|
+
const zodSchema = schema;
|
|
127
|
+
if (zodSchema.shape && typeof zodSchema.shape === 'object') {
|
|
128
|
+
// Basic Zod object schema conversion
|
|
129
|
+
const properties = {};
|
|
130
|
+
for (const [key, value] of Object.entries(zodSchema.shape)) {
|
|
131
|
+
properties[key] = { type: 'string' }; // Simplified - could be enhanced
|
|
132
|
+
if (value && typeof value === 'object' && '_def' in value) {
|
|
133
|
+
const def = value._def;
|
|
134
|
+
if (def.description) {
|
|
135
|
+
properties[key].description = def.description;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
type: 'object',
|
|
141
|
+
properties,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return { type: 'object', properties: {} };
|
|
145
|
+
}
|
|
146
|
+
// Already JSON Schema format
|
|
147
|
+
return schema;
|
|
148
|
+
}
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Bind tools to the model for function calling
|
|
153
|
+
*/
|
|
154
|
+
bindTools(tools, _kwargs) {
|
|
155
|
+
// Convert LangChain tools to Zihin format
|
|
156
|
+
this.boundTools = tools.map((tool) => {
|
|
157
|
+
// Handle different tool formats
|
|
158
|
+
if ('name' in tool && 'description' in tool) {
|
|
159
|
+
const structuredTool = tool;
|
|
160
|
+
return {
|
|
161
|
+
type: 'function',
|
|
162
|
+
function: {
|
|
163
|
+
name: structuredTool.name,
|
|
164
|
+
description: structuredTool.description,
|
|
165
|
+
parameters: this.schemaToJsonSchema(structuredTool.schema),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// Fallback for other formats
|
|
170
|
+
return {
|
|
171
|
+
type: 'function',
|
|
172
|
+
function: {
|
|
173
|
+
name: String(tool.name || 'unknown'),
|
|
174
|
+
description: String(tool.description || ''),
|
|
175
|
+
parameters: this.schemaToJsonSchema(tool.schema),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
// Return this model with tools bound (as a Runnable)
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Convert LangChain messages to Zihin API format
|
|
184
|
+
*/
|
|
185
|
+
convertMessages(messages) {
|
|
186
|
+
return messages.map((message) => {
|
|
187
|
+
const type = message._getType();
|
|
188
|
+
// Handle Tool Messages (results from tool calls)
|
|
189
|
+
if (type === 'tool') {
|
|
190
|
+
const toolMsg = message;
|
|
191
|
+
return {
|
|
192
|
+
role: 'tool',
|
|
193
|
+
content: typeof toolMsg.content === 'string' ? toolMsg.content : JSON.stringify(toolMsg.content),
|
|
194
|
+
tool_call_id: toolMsg.tool_call_id,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
// Handle AI Messages with tool calls
|
|
198
|
+
if (type === 'ai') {
|
|
199
|
+
const aiMsg = message;
|
|
200
|
+
const zihinMsg = {
|
|
201
|
+
role: 'assistant',
|
|
202
|
+
content: typeof aiMsg.content === 'string' ? aiMsg.content : JSON.stringify(aiMsg.content),
|
|
203
|
+
};
|
|
204
|
+
// Check for tool calls in the message
|
|
205
|
+
if (aiMsg.tool_calls && aiMsg.tool_calls.length > 0) {
|
|
206
|
+
zihinMsg.tool_calls = aiMsg.tool_calls.map((tc) => ({
|
|
207
|
+
id: tc.id || `call_${Date.now()}`,
|
|
208
|
+
type: 'function',
|
|
209
|
+
function: {
|
|
210
|
+
name: tc.name,
|
|
211
|
+
arguments: typeof tc.args === 'string' ? tc.args : JSON.stringify(tc.args),
|
|
212
|
+
},
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
return zihinMsg;
|
|
216
|
+
}
|
|
217
|
+
// Handle other message types
|
|
218
|
+
let role;
|
|
219
|
+
if (type === 'system') {
|
|
220
|
+
role = 'system';
|
|
221
|
+
}
|
|
222
|
+
else if (type === 'human') {
|
|
223
|
+
role = 'user';
|
|
224
|
+
}
|
|
225
|
+
else if (message instanceof messages_1.ChatMessage) {
|
|
226
|
+
const chatRole = message.role.toLowerCase();
|
|
227
|
+
if (chatRole === 'system') {
|
|
228
|
+
role = 'system';
|
|
229
|
+
}
|
|
230
|
+
else if (chatRole === 'assistant') {
|
|
231
|
+
role = 'assistant';
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
role = 'user';
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
role = 'user';
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
role,
|
|
242
|
+
content: typeof message.content === 'string' ? message.content : JSON.stringify(message.content),
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Call the Zihin API
|
|
248
|
+
*/
|
|
249
|
+
async _generate(messages, options, _runManager) {
|
|
250
|
+
let zihinMessages = this.convertMessages(messages);
|
|
251
|
+
// Truncamento de contexto (proteção contra custos excessivos)
|
|
252
|
+
if (this.maxContextMessages > 0 && zihinMessages.length > this.maxContextMessages) {
|
|
253
|
+
const systemMsg = zihinMessages.find((m) => m.role === 'system');
|
|
254
|
+
const otherMsgs = zihinMessages.filter((m) => m.role !== 'system');
|
|
255
|
+
const recentMsgs = otherMsgs.slice(-this.maxContextMessages);
|
|
256
|
+
zihinMessages = systemMsg ? [systemMsg, ...recentMsgs] : recentMsgs;
|
|
257
|
+
console.warn(`⚠️ [ZihinChatModel] Contexto truncado: ${messages.length} → ${zihinMessages.length} mensagens`);
|
|
258
|
+
}
|
|
259
|
+
const requestBody = {
|
|
260
|
+
model: this.modelName,
|
|
261
|
+
messages: zihinMessages,
|
|
262
|
+
options: {
|
|
263
|
+
temperature: options.temperature ?? this.temperature,
|
|
264
|
+
maxTokens: options.maxTokens ?? this.maxTokens,
|
|
265
|
+
topP: options.topP ?? this.topP,
|
|
266
|
+
frequencyPenalty: options.frequencyPenalty ?? this.frequencyPenalty,
|
|
267
|
+
presencePenalty: options.presencePenalty ?? this.presencePenalty,
|
|
268
|
+
// Novos campos opcionais
|
|
269
|
+
...(this.stop.length > 0 && { stop: this.stop }),
|
|
270
|
+
...(this.sessionId && { session_id: this.sessionId }),
|
|
271
|
+
call_source: this.buildCallSource(),
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
// Add tools if bound
|
|
275
|
+
if (this.boundTools.length > 0) {
|
|
276
|
+
requestBody.tools = this.boundTools;
|
|
277
|
+
requestBody.tool_choice = 'auto';
|
|
278
|
+
}
|
|
279
|
+
// Add context for auto-routing
|
|
280
|
+
if (this.modelName === 'auto') {
|
|
281
|
+
requestBody.context = {
|
|
282
|
+
task: this.taskType,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
// Usar _callWithRetry com timeout e exponential backoff
|
|
286
|
+
const response = await this._callWithRetry(requestBody);
|
|
287
|
+
if (!response.ok) {
|
|
288
|
+
throw new Error(`Zihin API error: ${response.status} ${response.statusText}`);
|
|
289
|
+
}
|
|
290
|
+
const result = (await response.json());
|
|
291
|
+
if (!result.success || !result.data) {
|
|
292
|
+
throw new Error(result.message || result.error || 'Zihin API returned an error');
|
|
293
|
+
}
|
|
294
|
+
// Build the AI message with potential tool calls
|
|
295
|
+
const aiMessageContent = result.data.content || '';
|
|
296
|
+
const toolCalls = result.data.tool_calls?.map((tc) => ({
|
|
297
|
+
id: tc.id,
|
|
298
|
+
name: tc.function.name,
|
|
299
|
+
args: JSON.parse(tc.function.arguments || '{}'),
|
|
300
|
+
type: 'tool_call',
|
|
301
|
+
}));
|
|
302
|
+
const aiMessage = new messages_1.AIMessage({
|
|
303
|
+
content: aiMessageContent,
|
|
304
|
+
tool_calls: toolCalls,
|
|
305
|
+
additional_kwargs: {
|
|
306
|
+
model: result.data.model,
|
|
307
|
+
provider: result.data.provider,
|
|
308
|
+
finish_reason: result.data.finish_reason,
|
|
309
|
+
autoRouting: result.data.autoRouting,
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
const generation = {
|
|
313
|
+
text: aiMessageContent,
|
|
314
|
+
message: aiMessage,
|
|
315
|
+
generationInfo: {
|
|
316
|
+
finish_reason: result.data.finish_reason,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
return {
|
|
320
|
+
generations: [generation],
|
|
321
|
+
llmOutput: {
|
|
322
|
+
tokenUsage: {
|
|
323
|
+
promptTokens: result.data.usage.prompt_tokens,
|
|
324
|
+
completionTokens: result.data.usage.completion_tokens,
|
|
325
|
+
totalTokens: result.data.usage.total_tokens,
|
|
326
|
+
},
|
|
327
|
+
model: result.data.model,
|
|
328
|
+
provider: result.data.provider,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* n8n Node: Zihin Chat Model
|
|
335
|
+
* Sub-node for AI Agents that provides Zihin LLM as a chat model with Tool Calling support
|
|
336
|
+
*/
|
|
337
|
+
class ZihinChatModel {
|
|
338
|
+
constructor() {
|
|
339
|
+
this.description = {
|
|
340
|
+
displayName: 'Zihin Chat Model',
|
|
341
|
+
name: 'lmChatZihin',
|
|
342
|
+
icon: 'file:zihin.png',
|
|
343
|
+
group: ['transform'],
|
|
344
|
+
version: 1,
|
|
345
|
+
description: 'Chat Model for Zihin LLM Gateway with intelligent provider routing and Tool Calling support',
|
|
346
|
+
defaults: {
|
|
347
|
+
name: 'Zihin Chat Model',
|
|
348
|
+
},
|
|
349
|
+
codex: {
|
|
350
|
+
categories: ['AI'],
|
|
351
|
+
subcategories: {
|
|
352
|
+
AI: ['Language Models', 'Chat Models (Recommended)'],
|
|
353
|
+
},
|
|
354
|
+
resources: {
|
|
355
|
+
primaryDocumentation: [
|
|
356
|
+
{
|
|
357
|
+
url: 'https://docs.zihin.ai',
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
// No inputs - this is a sub-node
|
|
363
|
+
inputs: [],
|
|
364
|
+
// Output to AI Agent as language model
|
|
365
|
+
outputs: [AI_LANGUAGE_MODEL_OUTPUT],
|
|
366
|
+
outputNames: ['Model'],
|
|
367
|
+
credentials: [
|
|
368
|
+
{
|
|
369
|
+
name: 'zihinApi',
|
|
370
|
+
required: true,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
properties: [
|
|
374
|
+
// Model Selection
|
|
375
|
+
{
|
|
376
|
+
displayName: 'Model',
|
|
377
|
+
name: 'model',
|
|
378
|
+
type: 'options',
|
|
379
|
+
required: true,
|
|
380
|
+
default: 'auto',
|
|
381
|
+
description: 'Modelo LLM a ser usado. Use "auto" para roteamento inteligente baseado na tarefa.',
|
|
382
|
+
options: [
|
|
383
|
+
{ name: 'Auto (Roteamento Inteligente)', value: 'auto' },
|
|
384
|
+
// OpenAI - GPT-5 Family
|
|
385
|
+
{ name: 'OpenAI - GPT-5', value: 'openai.gpt-5' },
|
|
386
|
+
{ name: 'OpenAI - GPT-5 Mini', value: 'openai.gpt-5-mini' },
|
|
387
|
+
{ name: 'OpenAI - GPT-5 Nano', value: 'openai.gpt-5-nano' },
|
|
388
|
+
// OpenAI - GPT-4.1 Family
|
|
389
|
+
{ name: 'OpenAI - GPT-4.1', value: 'openai.gpt-4.1' },
|
|
390
|
+
{ name: 'OpenAI - GPT-4.1 Mini', value: 'openai.gpt-4.1-mini' },
|
|
391
|
+
{ name: 'OpenAI - GPT-4.1 Nano', value: 'openai.gpt-4.1-nano' },
|
|
392
|
+
// Anthropic - Claude 4.5 Family
|
|
393
|
+
{ name: 'Anthropic - Claude Sonnet 4.5', value: 'anthropic.claude-sonnet-4-5-20250929' },
|
|
394
|
+
{ name: 'Anthropic - Claude Haiku 4.5', value: 'anthropic.claude-haiku-4-5-20251001' },
|
|
395
|
+
// Anthropic - Claude 4 Family
|
|
396
|
+
{ name: 'Anthropic - Claude Opus 4.1', value: 'anthropic.claude-opus-4-1-20250805' },
|
|
397
|
+
{ name: 'Anthropic - Claude Sonnet 4', value: 'anthropic.claude-sonnet-4-20250514' },
|
|
398
|
+
// Anthropic - Legacy
|
|
399
|
+
{ name: 'Anthropic - Claude 3.5 Haiku', value: 'anthropic.claude-3-5-haiku-20241022' },
|
|
400
|
+
// Google - Gemini Family
|
|
401
|
+
{ name: 'Google - Gemini 2.5 Flash Lite', value: 'google.gemini-2.5-flash-lite' },
|
|
402
|
+
{ name: 'Google - Gemini 2.0 Flash', value: 'google.gemini-2.0-flash' },
|
|
403
|
+
{ name: 'Google - Gemini 2.0 Flash Lite', value: 'google.gemini-2.0-flash-lite' },
|
|
404
|
+
// Grok - Grok-4 Family
|
|
405
|
+
{ name: 'Grok - Grok 4 Fast Reasoning', value: 'grok.grok-4-fast-reasoning' },
|
|
406
|
+
{ name: 'Grok - Grok 4 Fast', value: 'grok.grok-4-fast-non-reasoning' },
|
|
407
|
+
{ name: 'Grok - Grok 4', value: 'grok.grok-4-0709' },
|
|
408
|
+
{ name: 'Grok - Grok Code Fast', value: 'grok.grok-code-fast-1' },
|
|
409
|
+
// Grok - Grok-3 Family
|
|
410
|
+
{ name: 'Grok - Grok 3', value: 'grok.grok-3' },
|
|
411
|
+
{ name: 'Grok - Grok 3 Mini', value: 'grok.grok-3-mini' },
|
|
412
|
+
// Grok - Grok-2 Legacy
|
|
413
|
+
{ name: 'Grok - Grok 2', value: 'grok.grok-2-1212' },
|
|
414
|
+
{ name: 'Grok - Grok 2 Vision', value: 'grok.grok-2-vision-1212' },
|
|
415
|
+
],
|
|
416
|
+
},
|
|
417
|
+
// Task Type (conditional - only when model="auto")
|
|
418
|
+
{
|
|
419
|
+
displayName: 'Task Type',
|
|
420
|
+
name: 'taskType',
|
|
421
|
+
type: 'options',
|
|
422
|
+
default: 'tool_calling',
|
|
423
|
+
description: 'Tipo de tarefa para otimizar a seleção automática do modelo (usado apenas no modo Auto)',
|
|
424
|
+
displayOptions: {
|
|
425
|
+
show: {
|
|
426
|
+
model: ['auto'],
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
options: [
|
|
430
|
+
{ name: 'Tool Calling / Chamada de Ferramentas', value: 'tool_calling' },
|
|
431
|
+
{ name: 'Chat / Conversação', value: 'chat' },
|
|
432
|
+
{ name: 'Coding / Programação', value: 'coding' },
|
|
433
|
+
{ name: 'Analysis / Análise', value: 'analysis' },
|
|
434
|
+
{ name: 'Planning / Planejamento', value: 'planning' },
|
|
435
|
+
{ name: 'Creative / Criativo', value: 'creative' },
|
|
436
|
+
{ name: 'Data Query / Consulta de Dados', value: 'data_query' },
|
|
437
|
+
],
|
|
438
|
+
},
|
|
439
|
+
// Options (collapsible collection)
|
|
440
|
+
{
|
|
441
|
+
displayName: 'Options',
|
|
442
|
+
name: 'options',
|
|
443
|
+
type: 'collection',
|
|
444
|
+
placeholder: 'Add Option',
|
|
445
|
+
default: {},
|
|
446
|
+
options: [
|
|
447
|
+
{
|
|
448
|
+
displayName: 'Temperature',
|
|
449
|
+
name: 'temperature',
|
|
450
|
+
type: 'number',
|
|
451
|
+
typeOptions: {
|
|
452
|
+
minValue: 0,
|
|
453
|
+
maxValue: 2,
|
|
454
|
+
numberStepSize: 0.1,
|
|
455
|
+
},
|
|
456
|
+
default: 0.7,
|
|
457
|
+
description: 'Controla a criatividade (0 = determinístico, 2 = muito criativo)',
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
displayName: 'Max Tokens',
|
|
461
|
+
name: 'maxTokens',
|
|
462
|
+
type: 'number',
|
|
463
|
+
typeOptions: {
|
|
464
|
+
minValue: 1,
|
|
465
|
+
maxValue: 128000,
|
|
466
|
+
},
|
|
467
|
+
default: 4096,
|
|
468
|
+
description: 'Limite máximo de tokens na resposta',
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
displayName: 'Top P',
|
|
472
|
+
name: 'topP',
|
|
473
|
+
type: 'number',
|
|
474
|
+
typeOptions: {
|
|
475
|
+
minValue: 0,
|
|
476
|
+
maxValue: 1,
|
|
477
|
+
numberStepSize: 0.1,
|
|
478
|
+
},
|
|
479
|
+
default: 1,
|
|
480
|
+
description: 'Nucleus sampling (alternativa a temperature)',
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
displayName: 'Frequency Penalty',
|
|
484
|
+
name: 'frequencyPenalty',
|
|
485
|
+
type: 'number',
|
|
486
|
+
typeOptions: {
|
|
487
|
+
minValue: -2,
|
|
488
|
+
maxValue: 2,
|
|
489
|
+
numberStepSize: 0.1,
|
|
490
|
+
},
|
|
491
|
+
default: 0,
|
|
492
|
+
description: 'Reduz repetição de tokens frequentes',
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
displayName: 'Presence Penalty',
|
|
496
|
+
name: 'presencePenalty',
|
|
497
|
+
type: 'number',
|
|
498
|
+
typeOptions: {
|
|
499
|
+
minValue: -2,
|
|
500
|
+
maxValue: 2,
|
|
501
|
+
numberStepSize: 0.1,
|
|
502
|
+
},
|
|
503
|
+
default: 0,
|
|
504
|
+
description: 'Incentiva novos tópicos na resposta',
|
|
505
|
+
},
|
|
506
|
+
// Novas opções - Alta Prioridade
|
|
507
|
+
{
|
|
508
|
+
displayName: 'Timeout',
|
|
509
|
+
name: 'timeout',
|
|
510
|
+
type: 'number',
|
|
511
|
+
typeOptions: {
|
|
512
|
+
minValue: 1000,
|
|
513
|
+
maxValue: 300000,
|
|
514
|
+
},
|
|
515
|
+
default: 60000,
|
|
516
|
+
description: 'Tempo máximo de espera em milissegundos (padrão: 60s)',
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
displayName: 'Max Retries',
|
|
520
|
+
name: 'maxRetries',
|
|
521
|
+
type: 'number',
|
|
522
|
+
typeOptions: {
|
|
523
|
+
minValue: 0,
|
|
524
|
+
maxValue: 5,
|
|
525
|
+
},
|
|
526
|
+
default: 2,
|
|
527
|
+
description: 'Número máximo de tentativas em caso de falha (com exponential backoff)',
|
|
528
|
+
},
|
|
529
|
+
// Novas opções - Média Prioridade
|
|
530
|
+
{
|
|
531
|
+
displayName: 'Base URL Override',
|
|
532
|
+
name: 'baseUrl',
|
|
533
|
+
type: 'string',
|
|
534
|
+
default: '',
|
|
535
|
+
description: 'URL base alternativa (deixar vazio para usar padrão: llm.zihin.ai). Útil para testes locais.',
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
displayName: 'Max Context Messages',
|
|
539
|
+
name: 'maxContextMessages',
|
|
540
|
+
type: 'number',
|
|
541
|
+
typeOptions: {
|
|
542
|
+
minValue: 0,
|
|
543
|
+
maxValue: 100,
|
|
544
|
+
},
|
|
545
|
+
default: 0,
|
|
546
|
+
description: 'Limite de mensagens no contexto (0 = sem limite). Proteção contra custos excessivos.',
|
|
547
|
+
},
|
|
548
|
+
// Novas opções - Baixa Prioridade
|
|
549
|
+
{
|
|
550
|
+
displayName: 'Stop Sequences',
|
|
551
|
+
name: 'stop',
|
|
552
|
+
type: 'string',
|
|
553
|
+
default: '',
|
|
554
|
+
description: 'Sequências que interrompem a geração (separadas por vírgula)',
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
displayName: 'Session ID',
|
|
558
|
+
name: 'sessionId',
|
|
559
|
+
type: 'string',
|
|
560
|
+
default: '',
|
|
561
|
+
description: 'ID de sessão para manter contexto entre chamadas na API',
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
},
|
|
565
|
+
],
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Supply the LangChain chat model to the AI Agent
|
|
570
|
+
*/
|
|
571
|
+
async supplyData(itemIndex) {
|
|
572
|
+
// Get credentials
|
|
573
|
+
const credentials = await this.getCredentials('zihinApi');
|
|
574
|
+
const apiKey = credentials.apiKey;
|
|
575
|
+
// Get node parameters
|
|
576
|
+
const model = this.getNodeParameter('model', itemIndex);
|
|
577
|
+
const taskType = this.getNodeParameter('taskType', itemIndex, 'tool_calling');
|
|
578
|
+
const options = this.getNodeParameter('options', itemIndex, {});
|
|
579
|
+
// Extrair contexto para call_source dinâmico
|
|
580
|
+
const callSourceContext = {};
|
|
581
|
+
try {
|
|
582
|
+
const workflowDataProxy = this.getWorkflowDataProxy(itemIndex);
|
|
583
|
+
// Extrair informações do workflow (acesso seguro)
|
|
584
|
+
if (workflowDataProxy?.$workflow) {
|
|
585
|
+
const workflow = workflowDataProxy.$workflow;
|
|
586
|
+
if (typeof workflow === 'object') {
|
|
587
|
+
callSourceContext.workflowId = workflow.id ?? workflow.name;
|
|
588
|
+
callSourceContext.workflowName = workflow.name;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// Extrair nome do node atual
|
|
592
|
+
if (workflowDataProxy?.$node) {
|
|
593
|
+
const node = workflowDataProxy.$node;
|
|
594
|
+
if (typeof node === 'object' && node.name) {
|
|
595
|
+
callSourceContext.nodeName = node.name;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
// Extrair ID da execução (acesso alternativo)
|
|
599
|
+
if (workflowDataProxy?.$execution) {
|
|
600
|
+
const execution = workflowDataProxy.$execution;
|
|
601
|
+
if (typeof execution === 'object') {
|
|
602
|
+
callSourceContext.executionId = execution.id;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
// Se falhar ao extrair contexto, continuar com valores vazios
|
|
608
|
+
// Não é crítico - o call_source terá menos informações
|
|
609
|
+
}
|
|
610
|
+
// Create the LangChain chat model
|
|
611
|
+
const chatModel = new ZihinLangChainChatModel({
|
|
612
|
+
apiKey,
|
|
613
|
+
modelName: model,
|
|
614
|
+
taskType,
|
|
615
|
+
temperature: options.temperature,
|
|
616
|
+
maxTokens: options.maxTokens,
|
|
617
|
+
topP: options.topP,
|
|
618
|
+
frequencyPenalty: options.frequencyPenalty,
|
|
619
|
+
presencePenalty: options.presencePenalty,
|
|
620
|
+
// Novos campos
|
|
621
|
+
timeout: options.timeout,
|
|
622
|
+
maxRetries: options.maxRetries,
|
|
623
|
+
baseUrl: options.baseUrl,
|
|
624
|
+
maxContextMessages: options.maxContextMessages,
|
|
625
|
+
stop: options.stop,
|
|
626
|
+
sessionId: options.sessionId,
|
|
627
|
+
// Contexto para call_source dinâmico
|
|
628
|
+
callSourceContext,
|
|
629
|
+
});
|
|
630
|
+
return {
|
|
631
|
+
response: chatModel,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
exports.ZihinChatModel = ZihinChatModel;
|
|
636
|
+
//# sourceMappingURL=ZihinChatModel.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZihinChatModel.node.js","sourceRoot":"","sources":["../../../src/nodes/Z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AAM,SAAS,GAAG,IAAI,uBAAuB,CAAC;YAC7C,MAAM;YACN,SAAS,EAAE,KAAK;YAChB,QAAQ;YACR,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,eAAe;YACf,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;YAC9C,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,qCAAqC;YACrC,iBAAiB;SACjB,CAAC,CAAC;QAEH,OAAO;YACN,QAAQ,EAAE,SAAS;SACnB,CAAC;IACH,CAAC;CACD;AAnUD,wCAmUC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-zihin.lmChatZihin",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["AI"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://docs.zihin.ai/api-keys"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://docs.zihin.ai/n8n"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"alias": ["llm", "ai", "gpt", "claude", "gemini", "chat", "openai", "anthropic", "google", "grok", "langchain", "agent"],
|
|
19
|
+
"subcategories": {
|
|
20
|
+
"AI": ["Language Models", "Chat Models (Recommended)"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
@@ -277,7 +277,36 @@ class ZihinGateway {
|
|
|
277
277
|
name: 'sessionId',
|
|
278
278
|
type: 'string',
|
|
279
279
|
default: '',
|
|
280
|
-
description: 'ID de sessão para
|
|
280
|
+
description: 'ID de sessão para telemetria (API é stateless)',
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
displayName: 'Timeout',
|
|
284
|
+
name: 'timeout',
|
|
285
|
+
type: 'number',
|
|
286
|
+
typeOptions: {
|
|
287
|
+
minValue: 1000,
|
|
288
|
+
maxValue: 300000,
|
|
289
|
+
},
|
|
290
|
+
default: 60000,
|
|
291
|
+
description: 'Tempo máximo de espera em milissegundos (padrão: 60s)',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
displayName: 'Max Retries',
|
|
295
|
+
name: 'maxRetries',
|
|
296
|
+
type: 'number',
|
|
297
|
+
typeOptions: {
|
|
298
|
+
minValue: 0,
|
|
299
|
+
maxValue: 5,
|
|
300
|
+
},
|
|
301
|
+
default: 2,
|
|
302
|
+
description: 'Número máximo de tentativas em caso de falha (0-5)',
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
displayName: 'Base URL Override',
|
|
306
|
+
name: 'baseUrl',
|
|
307
|
+
type: 'string',
|
|
308
|
+
default: '',
|
|
309
|
+
description: 'URL base alternativa (deixar vazio para usar padrão: llm.zihin.ai)',
|
|
281
310
|
},
|
|
282
311
|
],
|
|
283
312
|
},
|
|
@@ -293,6 +322,21 @@ class ZihinGateway {
|
|
|
293
322
|
const model = this.getNodeParameter('model', itemIndex);
|
|
294
323
|
const inputType = this.getNodeParameter('inputType', itemIndex);
|
|
295
324
|
const options = this.getNodeParameter('options', itemIndex, {});
|
|
325
|
+
// Configuration with defaults
|
|
326
|
+
const timeout = options.timeout ?? 60000;
|
|
327
|
+
const maxRetries = options.maxRetries ?? 2;
|
|
328
|
+
const baseUrl = options.baseUrl || 'https://llm.zihin.ai';
|
|
329
|
+
// Build call_source for telemetry
|
|
330
|
+
let callSource = 'n8n_gateway';
|
|
331
|
+
try {
|
|
332
|
+
const workflowData = this.getWorkflow();
|
|
333
|
+
if (workflowData.id) {
|
|
334
|
+
callSource = `n8n_gateway.${workflowData.id}`;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// Ignore errors extracting workflow context
|
|
339
|
+
}
|
|
296
340
|
// Build request body
|
|
297
341
|
const body = {
|
|
298
342
|
model,
|
|
@@ -348,19 +392,63 @@ class ZihinGateway {
|
|
|
348
392
|
if (options.sessionId) {
|
|
349
393
|
requestOptions.session_id = options.sessionId;
|
|
350
394
|
}
|
|
395
|
+
// Always add call_source for telemetry
|
|
396
|
+
requestOptions.call_source = callSource;
|
|
351
397
|
if (Object.keys(requestOptions).length > 0) {
|
|
352
398
|
body.options = requestOptions;
|
|
353
399
|
}
|
|
354
|
-
// Make API request
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
400
|
+
// Make API request with retry logic
|
|
401
|
+
let response = null;
|
|
402
|
+
let lastError = null;
|
|
403
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
404
|
+
try {
|
|
405
|
+
response = await this.helpers.httpRequestWithAuthentication.call(this, 'zihinApi', {
|
|
406
|
+
method: 'POST',
|
|
407
|
+
url: `${baseUrl}/api/v3/llm/public/call`,
|
|
408
|
+
headers: {
|
|
409
|
+
'Content-Type': 'application/json',
|
|
410
|
+
},
|
|
411
|
+
body,
|
|
412
|
+
json: true,
|
|
413
|
+
timeout,
|
|
414
|
+
});
|
|
415
|
+
// Check if we should retry (5xx or 429)
|
|
416
|
+
if (!response.success && response.error) {
|
|
417
|
+
const shouldRetry = response.error === 'RATE_LIMIT_EXCEEDED' ||
|
|
418
|
+
response.error.includes('500') ||
|
|
419
|
+
response.error.includes('502') ||
|
|
420
|
+
response.error.includes('503') ||
|
|
421
|
+
response.error.includes('504');
|
|
422
|
+
if (shouldRetry && attempt < maxRetries) {
|
|
423
|
+
const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
|
|
424
|
+
console.warn(`⚠️ Zihin Gateway retry ${attempt + 1}/${maxRetries} após ${delay}ms`);
|
|
425
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// Success or non-retryable error
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
lastError = error;
|
|
434
|
+
// Check if it's a timeout or network error that should be retried
|
|
435
|
+
const errorMessage = error.message?.toLowerCase() || '';
|
|
436
|
+
const isRetryable = errorMessage.includes('timeout') ||
|
|
437
|
+
errorMessage.includes('econnreset') ||
|
|
438
|
+
errorMessage.includes('econnrefused') ||
|
|
439
|
+
errorMessage.includes('socket');
|
|
440
|
+
if (isRetryable && attempt < maxRetries) {
|
|
441
|
+
const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
|
|
442
|
+
console.warn(`⚠️ Zihin Gateway retry ${attempt + 1}/${maxRetries} após ${delay}ms (${errorMessage})`);
|
|
443
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (!response) {
|
|
450
|
+
throw lastError || new Error('Max retries exceeded');
|
|
451
|
+
}
|
|
364
452
|
// Handle response
|
|
365
453
|
if (!response.success) {
|
|
366
454
|
if (response.error === 'RATE_LIMIT_EXCEEDED') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZihinGateway.node.js","sourceRoot":"","sources":["../../../src/nodes/ZihinGateway/ZihinGateway.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAgEtB,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,mBAAmB;YAChC,IAA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1B,UAAU,CAAC,IAAI,CAAC;4BACd,IAAI,EAAE;gCACJ,KAAK,EAAE,KAAK,CAAC,OAAO;6BACrB;4BACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;yBAChC,CAAC,CAAC;wBACH,SAAS;oBACX,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;oBACrC,OAAO,EAAE,oCAAoC;oBAC7C,WAAW,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;iBAC1E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;CACF;AA7cD,oCA6cC"}
|
|
1
|
+
{"version":3,"file":"ZihinGateway.node.js","sourceRoot":"","sources":["../../../src/nodes/ZihinGateway/ZihinGateway.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAiEtB,MAAa,YAAY;IAAzB;QACE,gBAAW,GAAyB;YAClC,WAAW,EAAE,mBAAmB;YAChC,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,0BAA0B;YACpC,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE;gBACR,IAAI,EAAE,mBAAmB;aAC1B;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE,IAAI;iBACf;aACF;YACD,UAAU,EAAE;gBACV,kBAAkB;gBAClB;oBACE,WAAW,EAAE,OAAO;oBACpB,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,IAAI;oBACd,O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CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,2BAAY,IAAI,KAAK,YAAY,iCAAkB,EAAE,CAAC;oBACzE,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;wBAC1B,UAAU,CAAC,IAAI,CAAC;4BACd,IAAI,EAAE;gCACJ,KAAK,EAAE,KAAK,CAAC,OAAO;6BACrB;4BACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;yBAChC,CAAC,CAAC;wBACH,SAAS;oBACX,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;oBACrC,OAAO,EAAE,oCAAoC;oBAC7C,WAAW,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;iBAC1E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;CACF;AAjjBD,oCAijBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-zihin.zihinGateway",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": ["AI", "Development"],
|
|
6
|
+
"resources": {
|
|
7
|
+
"credentialDocumentation": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://docs.zihin.ai/api-keys"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"primaryDocumentation": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://docs.zihin.ai/n8n"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"alias": ["llm", "ai", "gpt", "claude", "gemini", "chat", "completion", "openai", "anthropic", "google"],
|
|
19
|
+
"subcategories": {
|
|
20
|
+
"AI": ["Language Models"]
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-zihin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "n8n node for Zihin LLM Gateway - Unified LLM API with intelligent provider routing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
"anthropic",
|
|
13
13
|
"claude",
|
|
14
14
|
"gpt",
|
|
15
|
-
"gemini"
|
|
15
|
+
"gemini",
|
|
16
|
+
"langchain",
|
|
17
|
+
"chat-model",
|
|
18
|
+
"ai-agent"
|
|
16
19
|
],
|
|
17
20
|
"license": "MIT",
|
|
18
21
|
"homepage": "https://zihin.ai",
|
|
@@ -26,7 +29,7 @@
|
|
|
26
29
|
},
|
|
27
30
|
"main": "dist/nodes/ZihinGateway/ZihinGateway.node.js",
|
|
28
31
|
"scripts": {
|
|
29
|
-
"build": "tsc && gulp build:icons",
|
|
32
|
+
"build": "tsc && gulp build:icons && gulp build:json",
|
|
30
33
|
"dev": "tsc --watch",
|
|
31
34
|
"lint": "eslint src --ext .ts",
|
|
32
35
|
"lint:fix": "eslint src --ext .ts --fix",
|
|
@@ -41,9 +44,13 @@
|
|
|
41
44
|
"dist/credentials/ZihinApi.credentials.js"
|
|
42
45
|
],
|
|
43
46
|
"nodes": [
|
|
44
|
-
"dist/nodes/ZihinGateway/ZihinGateway.node.js"
|
|
47
|
+
"dist/nodes/ZihinGateway/ZihinGateway.node.js",
|
|
48
|
+
"dist/nodes/ZihinChatModel/ZihinChatModel.node.js"
|
|
45
49
|
]
|
|
46
50
|
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@langchain/core": "^0.3.0"
|
|
53
|
+
},
|
|
47
54
|
"devDependencies": {
|
|
48
55
|
"@types/node": "^20.10.0",
|
|
49
56
|
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
@@ -54,7 +61,8 @@
|
|
|
54
61
|
"typescript": "^5.3.0"
|
|
55
62
|
},
|
|
56
63
|
"peerDependencies": {
|
|
57
|
-
"n8n-workflow": "*"
|
|
64
|
+
"n8n-workflow": "*",
|
|
65
|
+
"@langchain/core": ">=0.3.0"
|
|
58
66
|
},
|
|
59
67
|
"engines": {
|
|
60
68
|
"node": ">=18.0.0"
|