okeymeta-ai-sdk 1.0.4 → 1.0.5
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 +56 -13
- package/index.d.ts +10 -3
- package/package.json +1 -1
- package/src/okeymeta-client.js +6 -4
package/README.md
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
[](https://www.npmjs.com/package/okeymeta-ai-sdk)
|
17
17
|
[](https://www.npmjs.com/package/okeymeta-ai-sdk)
|
18
|
+
[](https://github.com/okeymeta/okeymeta-ai-sdk/actions)
|
18
19
|
|
19
20
|
---
|
20
21
|
|
@@ -75,7 +76,7 @@ const response = await client.textCompletion({
|
|
75
76
|
model: 'okeyai3.0-vanguard',
|
76
77
|
input: 'Tell me a fun fact about Nigeria.'
|
77
78
|
});
|
78
|
-
console.log(response);
|
79
|
+
console.log(response); // Only the AI's response string is returned
|
79
80
|
```
|
80
81
|
|
81
82
|
### 2. Image-to-Text
|
@@ -87,16 +88,16 @@ const imgResponse = await client.imageToText({
|
|
87
88
|
deepCognition: 'on',
|
88
89
|
reasoningFormat: 'parsed' // 'raw', 'parsed', or 'hidden'
|
89
90
|
});
|
90
|
-
console.log(imgResponse);
|
91
|
+
console.log(imgResponse); // Only the AI's response string is returned
|
91
92
|
```
|
92
93
|
|
93
94
|
### 3. Conversational AI (Context Managed)
|
94
95
|
```js
|
95
96
|
const conversation = client.startConversation('okeyai3.0-vanguard');
|
96
97
|
let reply = await conversation.send('Hello, who are you?');
|
97
|
-
console.log(reply
|
98
|
+
console.log(reply); // Only the AI's response string is returned
|
98
99
|
reply = await conversation.send('Tell me a joke.');
|
99
|
-
console.log(reply
|
100
|
+
console.log(reply); // Only the AI's response string is returned
|
100
101
|
```
|
101
102
|
|
102
103
|
### 4. Manual APiKey (Context Key) Override
|
@@ -108,10 +109,31 @@ const response = await client.textCompletion({
|
|
108
109
|
input: 'Continue our conversation.',
|
109
110
|
APiKey: 'okeymeta-your_conversation_key', // Must start with 'okeymeta-'
|
110
111
|
});
|
111
|
-
console.log(response);
|
112
|
+
console.log(response); // Only the AI's response string is returned
|
112
113
|
```
|
113
114
|
|
114
|
-
### 5. Advanced:
|
115
|
+
### 5. Advanced: Get the Full API Response (raw mode)
|
116
|
+
> If you want the full API response object (including model info, metrics, etc.), pass `{ raw: true }`:
|
117
|
+
```js
|
118
|
+
const fullTextResponse = await client.textCompletion({
|
119
|
+
model: 'okeyai3.0-vanguard',
|
120
|
+
input: 'Tell me a fun fact about Nigeria.',
|
121
|
+
raw: true
|
122
|
+
});
|
123
|
+
console.log(fullTextResponse); // Full API object
|
124
|
+
|
125
|
+
const fullImageResponse = await client.imageToText({
|
126
|
+
model: 'okeyai4.0-DeepCognition',
|
127
|
+
input: 'Describe this image in detail.',
|
128
|
+
imgUrl: 'https://example.com/image.jpg',
|
129
|
+
deepCognition: 'on',
|
130
|
+
reasoningFormat: 'parsed',
|
131
|
+
raw: true
|
132
|
+
});
|
133
|
+
console.log(fullImageResponse); // Full API object
|
134
|
+
```
|
135
|
+
|
136
|
+
### 6. Advanced: Custom Provider (Headers, Endpoints)
|
115
137
|
```js
|
116
138
|
import { createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
117
139
|
const okeymeta = createOkeyMetaProvider({
|
@@ -125,7 +147,7 @@ const response = await okeymeta.textCompletion({
|
|
125
147
|
model: 'okeyai2.0-basic',
|
126
148
|
input: 'What is OkeyMeta?'
|
127
149
|
});
|
128
|
-
console.log(response);
|
150
|
+
console.log(response); // Only the AI's response string is returned
|
129
151
|
```
|
130
152
|
|
131
153
|
---
|
@@ -183,6 +205,9 @@ A: Use `createOkeyMetaProvider` as shown above.
|
|
183
205
|
**Q: What happens if I forget the `okeymeta-` prefix on APiKey?**
|
184
206
|
A: The API will reject your request. Always use the correct prefix for manual context keys.
|
185
207
|
|
208
|
+
**Q: How do I get the full API response object?**
|
209
|
+
A: Pass `{ raw: true }` to `textCompletion` or `imageToText`.
|
210
|
+
|
186
211
|
---
|
187
212
|
|
188
213
|
## 🤖 Full Feature Test Script
|
@@ -197,7 +222,7 @@ import { OkeyMetaClient, createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
|
197
222
|
model: 'okeyai3.0-vanguard',
|
198
223
|
input: 'What is the capital of Nigeria?'
|
199
224
|
});
|
200
|
-
console.log('Text:', text);
|
225
|
+
console.log('Text:', text); // Only the AI's response string is returned
|
201
226
|
|
202
227
|
// Image-to-text
|
203
228
|
const image = await client.imageToText({
|
@@ -207,14 +232,14 @@ import { OkeyMetaClient, createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
|
207
232
|
deepCognition: 'on',
|
208
233
|
reasoningFormat: 'parsed'
|
209
234
|
});
|
210
|
-
console.log('Image:', image);
|
235
|
+
console.log('Image:', image); // Only the AI's response string is returned
|
211
236
|
|
212
237
|
// Conversation
|
213
238
|
const convo = client.startConversation('okeyai3.0-vanguard');
|
214
239
|
let reply = await convo.send('Who won the 2018 World Cup?');
|
215
|
-
console.log('AI:', reply
|
240
|
+
console.log('AI:', reply); // Only the AI's response string is returned
|
216
241
|
reply = await convo.send('And who was the top scorer?');
|
217
|
-
console.log('AI:', reply
|
242
|
+
console.log('AI:', reply); // Only the AI's response string is returned
|
218
243
|
|
219
244
|
// Manual APiKey override
|
220
245
|
const manual = await client.textCompletion({
|
@@ -222,7 +247,7 @@ import { OkeyMetaClient, createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
|
222
247
|
input: 'Continue with the previous context.',
|
223
248
|
APiKey: 'okeymeta-your_conversation_key', // Must start with 'okeymeta-'
|
224
249
|
});
|
225
|
-
console.log('Manual APiKey:', manual);
|
250
|
+
console.log('Manual APiKey:', manual); // Only the AI's response string is returned
|
226
251
|
|
227
252
|
// Custom provider
|
228
253
|
const custom = createOkeyMetaProvider({
|
@@ -233,7 +258,25 @@ import { OkeyMetaClient, createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
|
233
258
|
model: 'okeyai2.0-basic',
|
234
259
|
input: 'Custom provider test.'
|
235
260
|
});
|
236
|
-
console.log('Custom:', customResp);
|
261
|
+
console.log('Custom:', customResp); // Only the AI's response string is returned
|
262
|
+
|
263
|
+
// Full API response (raw mode)
|
264
|
+
const fullText = await client.textCompletion({
|
265
|
+
model: 'okeyai3.0-vanguard',
|
266
|
+
input: 'Show me everything.',
|
267
|
+
raw: true
|
268
|
+
});
|
269
|
+
console.log('Full API object (text):', fullText);
|
270
|
+
|
271
|
+
const fullImage = await client.imageToText({
|
272
|
+
model: 'okeyai4.0-DeepCognition',
|
273
|
+
input: 'Show me everything in this image.',
|
274
|
+
imgUrl: 'https://example.com/image.jpg',
|
275
|
+
deepCognition: 'on',
|
276
|
+
reasoningFormat: 'parsed',
|
277
|
+
raw: true
|
278
|
+
});
|
279
|
+
console.log('Full API object (image):', fullImage);
|
237
280
|
})();
|
238
281
|
```
|
239
282
|
|
package/index.d.ts
CHANGED
@@ -15,6 +15,7 @@ export interface TextCompletionParams {
|
|
15
15
|
input: string;
|
16
16
|
contextKey?: string;
|
17
17
|
APiKey?: string;
|
18
|
+
raw?: boolean;
|
18
19
|
[key: string]: any;
|
19
20
|
}
|
20
21
|
|
@@ -26,6 +27,7 @@ export interface ImageToTextParams {
|
|
26
27
|
APiKey?: string;
|
27
28
|
deepCognition?: string;
|
28
29
|
reasoningFormat?: 'raw' | 'parsed' | 'hidden';
|
30
|
+
raw?: boolean;
|
29
31
|
[key: string]: any;
|
30
32
|
}
|
31
33
|
|
@@ -50,13 +52,17 @@ export class OkeyMetaClient {
|
|
50
52
|
|
51
53
|
/**
|
52
54
|
* Generate or complete text using a specified model.
|
55
|
+
* Returns only the AI's response string by default. If { raw: true } is passed, returns the full API object.
|
53
56
|
*/
|
54
|
-
textCompletion(params: TextCompletionParams): Promise<ConversationResponse>;
|
57
|
+
textCompletion(params: TextCompletionParams & { raw: true }): Promise<ConversationResponse>;
|
58
|
+
textCompletion(params: TextCompletionParams): Promise<string>;
|
55
59
|
|
56
60
|
/**
|
57
61
|
* Generate text from an image using a specified model.
|
62
|
+
* Returns only the AI's response string by default. If { raw: true } is passed, returns the full API object.
|
58
63
|
*/
|
59
|
-
imageToText(params: ImageToTextParams): Promise<ConversationResponse>;
|
64
|
+
imageToText(params: ImageToTextParams & { raw: true }): Promise<ConversationResponse>;
|
65
|
+
imageToText(params: ImageToTextParams): Promise<string>;
|
60
66
|
|
61
67
|
/**
|
62
68
|
* Start a new conversation with a model.
|
@@ -82,6 +88,7 @@ export class Conversation {
|
|
82
88
|
|
83
89
|
/**
|
84
90
|
* Send a message and receive a response from the model.
|
91
|
+
* Returns only the AI's response string.
|
85
92
|
*/
|
86
|
-
send(input: string, params?: Record<string, any>): Promise<
|
93
|
+
send(input: string, params?: Record<string, any>): Promise<string>;
|
87
94
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "okeymeta-ai-sdk",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.5",
|
4
4
|
"description": "Official SDK for OkeyMeta AI models, including OkeyAI—Africa's first trained AI. Seamlessly integrate text, image, and conversational AI into any JavaScript project with enterprise-grade reliability and security.",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"types": "index.d.ts",
|
package/src/okeymeta-client.js
CHANGED
@@ -73,7 +73,7 @@ export class OkeyMetaClient {
|
|
73
73
|
this.endpoints = { ...DEFAULT_MODEL_ENDPOINTS, ...endpoints };
|
74
74
|
}
|
75
75
|
|
76
|
-
async textCompletion({ model = 'okeyai3.0-vanguard', input, contextKey, APiKey, ...params }) {
|
76
|
+
async textCompletion({ model = 'okeyai3.0-vanguard', input, contextKey, APiKey, raw = false, ...params }) {
|
77
77
|
if (!input) throw new Error('Input prompt is required.');
|
78
78
|
validateParams(model, { input, contextKey, APiKey, ...params });
|
79
79
|
const url = this.endpoints[model];
|
@@ -91,10 +91,11 @@ export class OkeyMetaClient {
|
|
91
91
|
return response.data;
|
92
92
|
}
|
93
93
|
}
|
94
|
-
return response.data;
|
94
|
+
if (raw) return response.data;
|
95
|
+
return response.data && typeof response.data.response === 'string' ? response.data.response : response.data;
|
95
96
|
}
|
96
97
|
|
97
|
-
async imageToText({ model = 'okeyai4.0-DeepCognition', input, imgUrl, contextKey, APiKey, ...params }) {
|
98
|
+
async imageToText({ model = 'okeyai4.0-DeepCognition', input, imgUrl, contextKey, APiKey, raw = false, ...params }) {
|
98
99
|
if (!input) throw new Error('Input prompt is required.');
|
99
100
|
if (!imgUrl) throw new Error('imgUrl is required for image-to-text.');
|
100
101
|
validateParams(model, { input, imgUrl, contextKey, APiKey, ...params });
|
@@ -113,7 +114,8 @@ export class OkeyMetaClient {
|
|
113
114
|
return response.data;
|
114
115
|
}
|
115
116
|
}
|
116
|
-
return response.data;
|
117
|
+
if (raw) return response.data;
|
118
|
+
return response.data && typeof response.data.response === 'string' ? response.data.response : response.data;
|
117
119
|
}
|
118
120
|
|
119
121
|
startConversation(model = 'okeyai3.0-vanguard', contextKey) {
|