@olane/o-tool-registry 0.6.1 → 0.6.2
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/package.json +8 -15
- package/dist/auth/index.d.ts +0 -4
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -3
- package/dist/auth/interfaces/index.d.ts +0 -4
- package/dist/auth/interfaces/index.d.ts.map +0 -1
- package/dist/auth/interfaces/index.js +0 -3
- package/dist/auth/interfaces/oAuth-tokens.interface.d.ts +0 -9
- package/dist/auth/interfaces/oAuth-tokens.interface.d.ts.map +0 -1
- package/dist/auth/interfaces/oAuth-tokens.interface.js +0 -1
- package/dist/auth/interfaces/oAuth-user-info.interface.d.ts +0 -8
- package/dist/auth/interfaces/oAuth-user-info.interface.d.ts.map +0 -1
- package/dist/auth/interfaces/oAuth-user-info.interface.js +0 -1
- package/dist/auth/interfaces/oAuth.config.d.ts +0 -14
- package/dist/auth/interfaces/oAuth.config.d.ts.map +0 -1
- package/dist/auth/interfaces/oAuth.config.js +0 -1
- package/dist/auth/methods/auth.methods.d.ts +0 -5
- package/dist/auth/methods/auth.methods.d.ts.map +0 -1
- package/dist/auth/methods/auth.methods.js +0 -302
- package/dist/auth/oAuth.tool.d.ts +0 -20
- package/dist/auth/oAuth.tool.d.ts.map +0 -1
- package/dist/auth/oAuth.tool.js +0 -419
- package/dist/embeddings/embeddings.tool.d.ts +0 -6
- package/dist/embeddings/embeddings.tool.d.ts.map +0 -1
- package/dist/embeddings/embeddings.tool.js +0 -11
- package/dist/embeddings/huggingface-text-embeddings.tool.d.ts +0 -9
- package/dist/embeddings/huggingface-text-embeddings.tool.d.ts.map +0 -1
- package/dist/embeddings/huggingface-text-embeddings.tool.js +0 -21
- package/dist/embeddings/index.d.ts +0 -4
- package/dist/embeddings/index.d.ts.map +0 -1
- package/dist/embeddings/index.js +0 -3
- package/dist/embeddings/methods/text-embeddings.method.d.ts +0 -5
- package/dist/embeddings/methods/text-embeddings.method.d.ts.map +0 -1
- package/dist/embeddings/methods/text-embeddings.method.js +0 -29
- package/dist/embeddings/text-embeddings.tool.d.ts +0 -9
- package/dist/embeddings/text-embeddings.tool.d.ts.map +0 -1
- package/dist/embeddings/text-embeddings.tool.js +0 -13
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6
- package/dist/init.d.ts +0 -3
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -36
- package/dist/intelligence/anthropic-intelligence.tool.d.ts +0 -224
- package/dist/intelligence/anthropic-intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/anthropic-intelligence.tool.js +0 -477
- package/dist/intelligence/gemini-intelligence.tool.d.ts +0 -29
- package/dist/intelligence/gemini-intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/gemini-intelligence.tool.js +0 -267
- package/dist/intelligence/index.d.ts +0 -6
- package/dist/intelligence/index.d.ts.map +0 -1
- package/dist/intelligence/index.js +0 -5
- package/dist/intelligence/intelligence.tool.d.ts +0 -11
- package/dist/intelligence/intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/intelligence.tool.js +0 -120
- package/dist/intelligence/methods/intelligence.methods.d.ts +0 -5
- package/dist/intelligence/methods/intelligence.methods.d.ts.map +0 -1
- package/dist/intelligence/methods/intelligence.methods.js +0 -98
- package/dist/intelligence/ollama-intelligence.tool.d.ts +0 -36
- package/dist/intelligence/ollama-intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/ollama-intelligence.tool.js +0 -312
- package/dist/intelligence/openai-intelligence.tool.d.ts +0 -30
- package/dist/intelligence/openai-intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/openai-intelligence.tool.js +0 -255
- package/dist/intelligence/perplexity-intelligence.tool.d.ts +0 -27
- package/dist/intelligence/perplexity-intelligence.tool.d.ts.map +0 -1
- package/dist/intelligence/perplexity-intelligence.tool.js +0 -309
- package/dist/mcp/index.d.ts +0 -3
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -2
- package/dist/mcp/mcp-bridge.tool.d.ts +0 -12
- package/dist/mcp/mcp-bridge.tool.d.ts.map +0 -1
- package/dist/mcp/mcp-bridge.tool.js +0 -126
- package/dist/mcp/mcp.tool.d.ts +0 -14
- package/dist/mcp/mcp.tool.d.ts.map +0 -1
- package/dist/mcp/mcp.tool.js +0 -83
- package/dist/mcp/methods/mcp-bridge.methods.d.ts +0 -5
- package/dist/mcp/methods/mcp-bridge.methods.d.ts.map +0 -1
- package/dist/mcp/methods/mcp-bridge.methods.js +0 -79
- package/dist/nlp/index.d.ts +0 -2
- package/dist/nlp/index.d.ts.map +0 -1
- package/dist/nlp/index.js +0 -1
- package/dist/nlp/methods/nlp.methods.d.ts +0 -5
- package/dist/nlp/methods/nlp.methods.d.ts.map +0 -1
- package/dist/nlp/methods/nlp.methods.js +0 -15
- package/dist/nlp/ner.tool.d.ts +0 -7
- package/dist/nlp/ner.tool.d.ts.map +0 -1
- package/dist/nlp/ner.tool.js +0 -25
- package/dist/src/intelligence/anthropic-intelligence.tool.d.ts +0 -224
- package/dist/src/intelligence/anthropic-intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/anthropic-intelligence.tool.js +0 -477
- package/dist/src/intelligence/gemini-intelligence.tool.d.ts +0 -29
- package/dist/src/intelligence/gemini-intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/gemini-intelligence.tool.js +0 -267
- package/dist/src/intelligence/index.d.ts +0 -6
- package/dist/src/intelligence/index.d.ts.map +0 -1
- package/dist/src/intelligence/index.js +0 -5
- package/dist/src/intelligence/intelligence.tool.d.ts +0 -11
- package/dist/src/intelligence/intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/intelligence.tool.js +0 -134
- package/dist/src/intelligence/methods/intelligence.methods.d.ts +0 -5
- package/dist/src/intelligence/methods/intelligence.methods.d.ts.map +0 -1
- package/dist/src/intelligence/methods/intelligence.methods.js +0 -132
- package/dist/src/intelligence/ollama-intelligence.tool.d.ts +0 -36
- package/dist/src/intelligence/ollama-intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/ollama-intelligence.tool.js +0 -312
- package/dist/src/intelligence/openai-intelligence.tool.d.ts +0 -30
- package/dist/src/intelligence/openai-intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/openai-intelligence.tool.js +0 -255
- package/dist/src/intelligence/perplexity-intelligence.tool.d.ts +0 -28
- package/dist/src/intelligence/perplexity-intelligence.tool.d.ts.map +0 -1
- package/dist/src/intelligence/perplexity-intelligence.tool.js +0 -310
- package/dist/src/mcp/index.d.ts +0 -3
- package/dist/src/mcp/index.d.ts.map +0 -1
- package/dist/src/mcp/index.js +0 -2
- package/dist/src/mcp/mcp-bridge.tool.d.ts +0 -12
- package/dist/src/mcp/mcp-bridge.tool.d.ts.map +0 -1
- package/dist/src/mcp/mcp-bridge.tool.js +0 -107
- package/dist/src/mcp/mcp.tool.d.ts +0 -15
- package/dist/src/mcp/mcp.tool.d.ts.map +0 -1
- package/dist/src/mcp/mcp.tool.js +0 -85
- package/dist/src/mcp/methods/mcp-bridge.methods.d.ts +0 -5
- package/dist/src/mcp/methods/mcp-bridge.methods.d.ts.map +0 -1
- package/dist/src/mcp/methods/mcp-bridge.methods.js +0 -58
- package/dist/vector-store/index.d.ts +0 -3
- package/dist/vector-store/index.d.ts.map +0 -1
- package/dist/vector-store/index.js +0 -2
- package/dist/vector-store/langchain-memory.vector-store.tool.d.ts +0 -14
- package/dist/vector-store/langchain-memory.vector-store.tool.d.ts.map +0 -1
- package/dist/vector-store/langchain-memory.vector-store.tool.js +0 -60
- package/dist/vector-store/methods/vector-store.methods.d.ts +0 -5
- package/dist/vector-store/methods/vector-store.methods.d.ts.map +0 -1
- package/dist/vector-store/methods/vector-store.methods.js +0 -60
- package/dist/vector-store/vector-memory.tool.d.ts +0 -11
- package/dist/vector-store/vector-memory.tool.d.ts.map +0 -1
- package/dist/vector-store/vector-memory.tool.js +0 -13
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import { oAddress } from '@olane/o-core';
|
|
2
|
-
import { oVirtualTool } from '@olane/o-tool';
|
|
3
|
-
import { INTELLIGENCE_PARAMS } from './methods/intelligence.methods.js';
|
|
4
|
-
export class OllamaIntelligenceTool extends oVirtualTool {
|
|
5
|
-
constructor(config) {
|
|
6
|
-
super({
|
|
7
|
-
...config,
|
|
8
|
-
address: new oAddress('o://ollama'),
|
|
9
|
-
description: 'Intelligence tool using Ollama LLM suite of models',
|
|
10
|
-
methods: INTELLIGENCE_PARAMS,
|
|
11
|
-
dependencies: [],
|
|
12
|
-
});
|
|
13
|
-
// this.baseUrl = config.ollamaUrl || 'http://localhost:11434';
|
|
14
|
-
// this.defaultModel = config.defaultModel || 'llama2';
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Chat completion with Ollama
|
|
18
|
-
*/
|
|
19
|
-
async _tool_completion(request) {
|
|
20
|
-
try {
|
|
21
|
-
const params = request.params;
|
|
22
|
-
const { model = OllamaIntelligenceTool.defaultModel, messages, options = {}, } = params;
|
|
23
|
-
// let's validate the params and ask for ones that are missing
|
|
24
|
-
if (!messages || !Array.isArray(messages)) {
|
|
25
|
-
return {
|
|
26
|
-
success: false,
|
|
27
|
-
error: '"messages" array is required',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const chatRequest = {
|
|
31
|
-
model: model,
|
|
32
|
-
messages: messages,
|
|
33
|
-
stream: false,
|
|
34
|
-
options: options,
|
|
35
|
-
};
|
|
36
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/chat`, {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers: {
|
|
39
|
-
'Content-Type': 'application/json',
|
|
40
|
-
},
|
|
41
|
-
body: JSON.stringify(chatRequest),
|
|
42
|
-
});
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
const errorText = await response.text();
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const result = (await response.json());
|
|
51
|
-
return {
|
|
52
|
-
message: result.message.content,
|
|
53
|
-
model: result.model,
|
|
54
|
-
total_duration: result.total_duration,
|
|
55
|
-
eval_count: result.eval_count,
|
|
56
|
-
eval_duration: result.eval_duration,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
return {
|
|
61
|
-
success: false,
|
|
62
|
-
error: `Failed to complete chat: ${error.message}`,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Generate text with Ollama
|
|
68
|
-
*/
|
|
69
|
-
async _tool_generate(request) {
|
|
70
|
-
try {
|
|
71
|
-
const params = request.params;
|
|
72
|
-
const { model = OllamaIntelligenceTool.defaultModel, prompt, system, options = {}, } = params;
|
|
73
|
-
if (!prompt) {
|
|
74
|
-
return {
|
|
75
|
-
success: false,
|
|
76
|
-
error: 'Prompt is required',
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const generateRequest = {
|
|
80
|
-
model: model,
|
|
81
|
-
prompt: prompt,
|
|
82
|
-
system: system,
|
|
83
|
-
stream: false,
|
|
84
|
-
options: options,
|
|
85
|
-
};
|
|
86
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/generate`, {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: {
|
|
89
|
-
'Content-Type': 'application/json',
|
|
90
|
-
},
|
|
91
|
-
body: JSON.stringify(generateRequest),
|
|
92
|
-
});
|
|
93
|
-
if (!response.ok) {
|
|
94
|
-
const errorText = await response.text();
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const result = (await response.json());
|
|
101
|
-
return {
|
|
102
|
-
success: true,
|
|
103
|
-
response: result.response,
|
|
104
|
-
model: result.model,
|
|
105
|
-
done: result.done,
|
|
106
|
-
total_duration: result.total_duration,
|
|
107
|
-
eval_count: result.eval_count,
|
|
108
|
-
eval_duration: result.eval_duration,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
return {
|
|
113
|
-
success: false,
|
|
114
|
-
error: `Failed to generate text: ${error.message}`,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* List available models
|
|
120
|
-
*/
|
|
121
|
-
async _tool_list_models(request) {
|
|
122
|
-
try {
|
|
123
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/tags`, {
|
|
124
|
-
method: 'GET',
|
|
125
|
-
headers: {
|
|
126
|
-
'Content-Type': 'application/json',
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
if (!response.ok) {
|
|
130
|
-
const errorText = await response.text();
|
|
131
|
-
return {
|
|
132
|
-
success: false,
|
|
133
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
const result = (await response.json());
|
|
137
|
-
return {
|
|
138
|
-
success: true,
|
|
139
|
-
models: result.models,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
return {
|
|
144
|
-
success: false,
|
|
145
|
-
error: `Failed to list models: ${error.message}`,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Pull a model from Ollama library
|
|
151
|
-
*/
|
|
152
|
-
async _tool_pull_model(request) {
|
|
153
|
-
try {
|
|
154
|
-
const params = request.params;
|
|
155
|
-
const { model, insecure = false } = params;
|
|
156
|
-
if (!model) {
|
|
157
|
-
return {
|
|
158
|
-
success: false,
|
|
159
|
-
error: 'Model name is required',
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/pull`, {
|
|
163
|
-
method: 'POST',
|
|
164
|
-
headers: {
|
|
165
|
-
'Content-Type': 'application/json',
|
|
166
|
-
},
|
|
167
|
-
body: JSON.stringify({
|
|
168
|
-
name: model,
|
|
169
|
-
insecure: insecure,
|
|
170
|
-
}),
|
|
171
|
-
});
|
|
172
|
-
if (!response.ok) {
|
|
173
|
-
const errorText = await response.text();
|
|
174
|
-
return {
|
|
175
|
-
success: false,
|
|
176
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
// For pull operations, we need to handle streaming response
|
|
180
|
-
const reader = response.body?.getReader();
|
|
181
|
-
if (!reader) {
|
|
182
|
-
return {
|
|
183
|
-
success: false,
|
|
184
|
-
error: 'Failed to read response stream',
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
let result = '';
|
|
188
|
-
while (true) {
|
|
189
|
-
const { done, value } = await reader.read();
|
|
190
|
-
if (done)
|
|
191
|
-
break;
|
|
192
|
-
const chunk = new TextDecoder().decode(value);
|
|
193
|
-
result += chunk;
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
message: `Model ${model} pulled successfully`,
|
|
198
|
-
details: result,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
return {
|
|
203
|
-
success: false,
|
|
204
|
-
error: `Failed to pull model: ${error.message}`,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Delete a model
|
|
210
|
-
*/
|
|
211
|
-
async _tool_delete_model(request) {
|
|
212
|
-
try {
|
|
213
|
-
const params = request.params;
|
|
214
|
-
const { model } = params;
|
|
215
|
-
if (!model) {
|
|
216
|
-
return {
|
|
217
|
-
success: false,
|
|
218
|
-
error: 'Model name is required',
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/delete`, {
|
|
222
|
-
method: 'DELETE',
|
|
223
|
-
headers: {
|
|
224
|
-
'Content-Type': 'application/json',
|
|
225
|
-
},
|
|
226
|
-
body: JSON.stringify({
|
|
227
|
-
name: model,
|
|
228
|
-
}),
|
|
229
|
-
});
|
|
230
|
-
if (!response.ok) {
|
|
231
|
-
const errorText = await response.text();
|
|
232
|
-
return {
|
|
233
|
-
success: false,
|
|
234
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
success: true,
|
|
239
|
-
message: `Model ${model} deleted successfully`,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
return {
|
|
244
|
-
success: false,
|
|
245
|
-
error: `Failed to delete model: ${error.message}`,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Get model information
|
|
251
|
-
*/
|
|
252
|
-
async _tool_model_info(request) {
|
|
253
|
-
try {
|
|
254
|
-
const params = request.params;
|
|
255
|
-
const { model = OllamaIntelligenceTool.defaultModel } = params;
|
|
256
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/show`, {
|
|
257
|
-
method: 'POST',
|
|
258
|
-
headers: {
|
|
259
|
-
'Content-Type': 'application/json',
|
|
260
|
-
},
|
|
261
|
-
body: JSON.stringify({
|
|
262
|
-
name: model,
|
|
263
|
-
}),
|
|
264
|
-
});
|
|
265
|
-
if (!response.ok) {
|
|
266
|
-
const errorText = await response.text();
|
|
267
|
-
return {
|
|
268
|
-
success: false,
|
|
269
|
-
error: `Ollama API error: ${response.status} - ${errorText}`,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
const result = (await response.json());
|
|
273
|
-
return {
|
|
274
|
-
success: true,
|
|
275
|
-
model_info: result,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
return {
|
|
280
|
-
success: false,
|
|
281
|
-
error: `Failed to get model info: ${error.message}`,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Check Ollama server status
|
|
287
|
-
*/
|
|
288
|
-
async _tool_status(request) {
|
|
289
|
-
try {
|
|
290
|
-
const response = await fetch(`${OllamaIntelligenceTool.defaultUrl}/api/tags`, {
|
|
291
|
-
method: 'GET',
|
|
292
|
-
headers: {
|
|
293
|
-
'Content-Type': 'application/json',
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
return {
|
|
297
|
-
success: response.ok,
|
|
298
|
-
status: response.ok ? 'online' : 'offline',
|
|
299
|
-
status_code: response.status,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
catch (error) {
|
|
303
|
-
return {
|
|
304
|
-
success: false,
|
|
305
|
-
status: 'offline',
|
|
306
|
-
error: `Connection failed: ${error.message}`,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
OllamaIntelligenceTool.defaultModel = 'llama3.2:latest';
|
|
312
|
-
OllamaIntelligenceTool.defaultUrl = 'http://localhost:11434';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { oRequest } from '@olane/o-core';
|
|
2
|
-
import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
3
|
-
export declare class OpenAIIntelligenceTool extends oVirtualTool {
|
|
4
|
-
private apiKey;
|
|
5
|
-
private baseUrl;
|
|
6
|
-
private defaultModel;
|
|
7
|
-
private organization?;
|
|
8
|
-
constructor(config: oToolConfig);
|
|
9
|
-
/**
|
|
10
|
-
* Chat completion with OpenAI
|
|
11
|
-
*/
|
|
12
|
-
_tool_completion(request: oRequest): Promise<ToolResult>;
|
|
13
|
-
/**
|
|
14
|
-
* Generate text with OpenAI
|
|
15
|
-
*/
|
|
16
|
-
_tool_generate(request: oRequest): Promise<ToolResult>;
|
|
17
|
-
/**
|
|
18
|
-
* List available models
|
|
19
|
-
*/
|
|
20
|
-
_tool_list_models(request: oRequest): Promise<ToolResult>;
|
|
21
|
-
/**
|
|
22
|
-
* Get model information
|
|
23
|
-
*/
|
|
24
|
-
_tool_model_info(request: oRequest): Promise<ToolResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Check OpenAI API status
|
|
27
|
-
*/
|
|
28
|
-
_tool_status(request: oRequest): Promise<ToolResult>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=openai-intelligence.tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openai-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence/openai-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoHtE,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAoE9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAmE5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA6C/D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+C9D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAoC3D"}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { oAddress } from '@olane/o-core';
|
|
2
|
-
import { oVirtualTool } from '@olane/o-tool';
|
|
3
|
-
import { INTELLIGENCE_PARAMS } from './methods/intelligence.methods.js';
|
|
4
|
-
export class OpenAIIntelligenceTool extends oVirtualTool {
|
|
5
|
-
constructor(config) {
|
|
6
|
-
super({
|
|
7
|
-
...config,
|
|
8
|
-
address: new oAddress('o://openai'),
|
|
9
|
-
description: "Open AI's suite of intelligence models.",
|
|
10
|
-
methods: INTELLIGENCE_PARAMS,
|
|
11
|
-
dependencies: [],
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Chat completion with OpenAI
|
|
16
|
-
*/
|
|
17
|
-
async _tool_completion(request) {
|
|
18
|
-
try {
|
|
19
|
-
const params = request.params;
|
|
20
|
-
const { model = this.defaultModel, messages, ...options } = params;
|
|
21
|
-
if (!this.apiKey) {
|
|
22
|
-
return {
|
|
23
|
-
success: false,
|
|
24
|
-
error: 'OpenAI API key is required',
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (!messages || !Array.isArray(messages)) {
|
|
28
|
-
return {
|
|
29
|
-
success: false,
|
|
30
|
-
error: '"messages" array is required',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const chatRequest = {
|
|
34
|
-
model: model,
|
|
35
|
-
messages: messages,
|
|
36
|
-
stream: false,
|
|
37
|
-
...options,
|
|
38
|
-
};
|
|
39
|
-
const headers = {
|
|
40
|
-
'Content-Type': 'application/json',
|
|
41
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
42
|
-
};
|
|
43
|
-
if (this.organization) {
|
|
44
|
-
headers['OpenAI-Organization'] = this.organization;
|
|
45
|
-
}
|
|
46
|
-
const response = await fetch(`${this.baseUrl}/chat/completions`, {
|
|
47
|
-
method: 'POST',
|
|
48
|
-
headers,
|
|
49
|
-
body: JSON.stringify(chatRequest),
|
|
50
|
-
});
|
|
51
|
-
if (!response.ok) {
|
|
52
|
-
const errorText = await response.text();
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
error: `OpenAI API error: ${response.status} - ${errorText}`,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const result = (await response.json());
|
|
59
|
-
return {
|
|
60
|
-
success: true,
|
|
61
|
-
response: result.choices[0]?.message?.content || '',
|
|
62
|
-
model: result.model,
|
|
63
|
-
usage: result.usage,
|
|
64
|
-
finish_reason: result.choices[0]?.finish_reason,
|
|
65
|
-
function_call: result.choices[0]?.message?.function_call,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
return {
|
|
70
|
-
success: false,
|
|
71
|
-
error: `Failed to complete chat: ${error.message}`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Generate text with OpenAI
|
|
77
|
-
*/
|
|
78
|
-
async _tool_generate(request) {
|
|
79
|
-
try {
|
|
80
|
-
const params = request.params;
|
|
81
|
-
const { model = this.defaultModel, prompt, ...options } = params;
|
|
82
|
-
if (!this.apiKey) {
|
|
83
|
-
return {
|
|
84
|
-
success: false,
|
|
85
|
-
error: 'OpenAI API key is required',
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (!prompt) {
|
|
89
|
-
return {
|
|
90
|
-
success: false,
|
|
91
|
-
error: 'Prompt is required',
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
const completionRequest = {
|
|
95
|
-
model: model,
|
|
96
|
-
prompt: prompt,
|
|
97
|
-
stream: false,
|
|
98
|
-
...options,
|
|
99
|
-
};
|
|
100
|
-
const headers = {
|
|
101
|
-
'Content-Type': 'application/json',
|
|
102
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
103
|
-
};
|
|
104
|
-
// if (this.organization) {
|
|
105
|
-
// headers['OpenAI-Organization'] = this.organization;
|
|
106
|
-
// }
|
|
107
|
-
const response = await fetch(`${this.baseUrl}/completions`, {
|
|
108
|
-
method: 'POST',
|
|
109
|
-
headers,
|
|
110
|
-
body: JSON.stringify(completionRequest),
|
|
111
|
-
});
|
|
112
|
-
if (!response.ok) {
|
|
113
|
-
const errorText = await response.text();
|
|
114
|
-
return {
|
|
115
|
-
success: false,
|
|
116
|
-
error: `OpenAI API error: ${response.status} - ${errorText}`,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const result = (await response.json());
|
|
120
|
-
return {
|
|
121
|
-
success: true,
|
|
122
|
-
response: result.choices[0]?.text || '',
|
|
123
|
-
model: result.model,
|
|
124
|
-
usage: result.usage,
|
|
125
|
-
finish_reason: result.choices[0]?.finish_reason,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
return {
|
|
130
|
-
success: false,
|
|
131
|
-
error: `Failed to generate text: ${error.message}`,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* List available models
|
|
137
|
-
*/
|
|
138
|
-
async _tool_list_models(request) {
|
|
139
|
-
try {
|
|
140
|
-
if (!this.apiKey) {
|
|
141
|
-
return {
|
|
142
|
-
success: false,
|
|
143
|
-
error: 'OpenAI API key is required',
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
const headers = {
|
|
147
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
148
|
-
};
|
|
149
|
-
if (this.organization) {
|
|
150
|
-
headers['OpenAI-Organization'] = this.organization;
|
|
151
|
-
}
|
|
152
|
-
const response = await fetch(`${this.baseUrl}/models`, {
|
|
153
|
-
method: 'GET',
|
|
154
|
-
headers,
|
|
155
|
-
});
|
|
156
|
-
if (!response.ok) {
|
|
157
|
-
const errorText = await response.text();
|
|
158
|
-
return {
|
|
159
|
-
success: false,
|
|
160
|
-
error: `OpenAI API error: ${response.status} - ${errorText}`,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
const result = (await response.json());
|
|
164
|
-
return {
|
|
165
|
-
success: true,
|
|
166
|
-
models: result.data,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
return {
|
|
171
|
-
success: false,
|
|
172
|
-
error: `Failed to list models: ${error.message}`,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Get model information
|
|
178
|
-
*/
|
|
179
|
-
async _tool_model_info(request) {
|
|
180
|
-
try {
|
|
181
|
-
const params = request.params;
|
|
182
|
-
const { model = this.defaultModel } = params;
|
|
183
|
-
if (!this.apiKey) {
|
|
184
|
-
return {
|
|
185
|
-
success: false,
|
|
186
|
-
error: 'OpenAI API key is required',
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
const headers = {
|
|
190
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
191
|
-
};
|
|
192
|
-
if (this.organization) {
|
|
193
|
-
headers['OpenAI-Organization'] = this.organization;
|
|
194
|
-
}
|
|
195
|
-
const response = await fetch(`${this.baseUrl}/models/${model}`, {
|
|
196
|
-
method: 'GET',
|
|
197
|
-
headers,
|
|
198
|
-
});
|
|
199
|
-
if (!response.ok) {
|
|
200
|
-
const errorText = await response.text();
|
|
201
|
-
return {
|
|
202
|
-
success: false,
|
|
203
|
-
error: `OpenAI API error: ${response.status} - ${errorText}`,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const result = (await response.json());
|
|
207
|
-
return {
|
|
208
|
-
success: true,
|
|
209
|
-
model_info: result,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
return {
|
|
214
|
-
success: false,
|
|
215
|
-
error: `Failed to get model info: ${error.message}`,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Check OpenAI API status
|
|
221
|
-
*/
|
|
222
|
-
async _tool_status(request) {
|
|
223
|
-
try {
|
|
224
|
-
if (!this.apiKey) {
|
|
225
|
-
return {
|
|
226
|
-
success: false,
|
|
227
|
-
status: 'no_api_key',
|
|
228
|
-
error: 'OpenAI API key is required',
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
const headers = {
|
|
232
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
233
|
-
};
|
|
234
|
-
if (this.organization) {
|
|
235
|
-
headers['OpenAI-Organization'] = this.organization;
|
|
236
|
-
}
|
|
237
|
-
const response = await fetch(`${this.baseUrl}/models`, {
|
|
238
|
-
method: 'GET',
|
|
239
|
-
headers,
|
|
240
|
-
});
|
|
241
|
-
return {
|
|
242
|
-
success: response.ok,
|
|
243
|
-
status: response.ok ? 'online' : 'offline',
|
|
244
|
-
status_code: response.status,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
catch (error) {
|
|
248
|
-
return {
|
|
249
|
-
success: false,
|
|
250
|
-
status: 'offline',
|
|
251
|
-
error: `Connection failed: ${error.message}`,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { oRequest } from '@olane/o-core';
|
|
2
|
-
import { oToolConfig, oVirtualTool, ToolResult } from '@olane/o-tool';
|
|
3
|
-
export declare class PerplexityIntelligenceTool extends oVirtualTool {
|
|
4
|
-
private defaultModel;
|
|
5
|
-
constructor(config: oToolConfig);
|
|
6
|
-
/**
|
|
7
|
-
* Chat completion with Perplexity
|
|
8
|
-
*/
|
|
9
|
-
_tool_completion(request: oRequest): Promise<ToolResult>;
|
|
10
|
-
/**
|
|
11
|
-
* Generate text with Perplexity (alias for completion)
|
|
12
|
-
*/
|
|
13
|
-
_tool_generate(request: oRequest): Promise<ToolResult>;
|
|
14
|
-
/**
|
|
15
|
-
* List available models
|
|
16
|
-
*/
|
|
17
|
-
_tool_list_models(request: oRequest): Promise<ToolResult>;
|
|
18
|
-
/**
|
|
19
|
-
* Search with Perplexity
|
|
20
|
-
*/
|
|
21
|
-
_tool_search(request: oRequest): Promise<ToolResult>;
|
|
22
|
-
/**
|
|
23
|
-
* Check Perplexity API status
|
|
24
|
-
*/
|
|
25
|
-
_tool_status(request: oRequest): Promise<ToolResult>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=perplexity-intelligence.tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"perplexity-intelligence.tool.d.ts","sourceRoot":"","sources":["../../src/intelligence/perplexity-intelligence.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAqFtE,qBAAa,0BAA2B,SAAQ,YAAY;IAC1D,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA+F9D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAuG5D;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAyC/D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IA6E1D;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CAgC3D"}
|