@reverbia/sdk 1.0.0-next.20251208102554 → 1.0.0-next.20251208112742
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 +104 -0
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.mts +24 -29
- package/dist/react/index.d.ts +24 -29
- package/dist/react/index.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -177,6 +177,110 @@ if (response.data) {
|
|
|
177
177
|
}
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
## React Native (Expo)
|
|
181
|
+
|
|
182
|
+
The SDK supports React Native via Expo with streaming support. For a complete
|
|
183
|
+
example, see
|
|
184
|
+
[ai-example-expo](https://github.com/zeta-chain/ai-example-expo).
|
|
185
|
+
|
|
186
|
+
### Installation
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pnpm install @reverbia/sdk@next web-streams-polyfill react-native-get-random-values @ethersproject/shims buffer
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Polyfill Setup
|
|
193
|
+
|
|
194
|
+
Create a custom entry point file (e.g., `entrypoint.js`) and update
|
|
195
|
+
`package.json` to use it:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"main": "entrypoint.js"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
// entrypoint.js
|
|
205
|
+
|
|
206
|
+
// Import polyfills in this exact order
|
|
207
|
+
import "react-native-get-random-values";
|
|
208
|
+
import "@ethersproject/shims";
|
|
209
|
+
import { Buffer } from "buffer";
|
|
210
|
+
global.Buffer = Buffer;
|
|
211
|
+
|
|
212
|
+
// Web Streams polyfill for SSE streaming
|
|
213
|
+
import { ReadableStream, TransformStream } from "web-streams-polyfill";
|
|
214
|
+
if (typeof globalThis.ReadableStream === "undefined") {
|
|
215
|
+
globalThis.ReadableStream = ReadableStream;
|
|
216
|
+
}
|
|
217
|
+
if (typeof globalThis.TransformStream === "undefined") {
|
|
218
|
+
globalThis.TransformStream = TransformStream;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// SDK polyfills (TextDecoderStream for streaming)
|
|
222
|
+
import "@reverbia/sdk/polyfills";
|
|
223
|
+
|
|
224
|
+
// Then import expo router
|
|
225
|
+
import "expo-router/entry";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Usage
|
|
229
|
+
|
|
230
|
+
Import from `@reverbia/sdk/expo` instead of `@reverbia/sdk/react`:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { useIdentityToken } from "@privy-io/expo";
|
|
234
|
+
import { useChat } from "@reverbia/sdk/expo";
|
|
235
|
+
|
|
236
|
+
function ChatComponent() {
|
|
237
|
+
const { getIdentityToken } = useIdentityToken();
|
|
238
|
+
|
|
239
|
+
const { isLoading, sendMessage } = useChat({
|
|
240
|
+
getToken: getIdentityToken,
|
|
241
|
+
baseUrl: "https://ai-portal-dev.zetachain.com",
|
|
242
|
+
onData: (chunk) => {
|
|
243
|
+
// Handle streaming chunks
|
|
244
|
+
const content =
|
|
245
|
+
typeof chunk === "string"
|
|
246
|
+
? chunk
|
|
247
|
+
: chunk.choices?.[0]?.delta?.content || "";
|
|
248
|
+
console.log("Received:", content);
|
|
249
|
+
},
|
|
250
|
+
onFinish: () => {
|
|
251
|
+
console.log("Stream finished");
|
|
252
|
+
},
|
|
253
|
+
onError: (error) => {
|
|
254
|
+
console.error("Error:", error);
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const handleSend = async () => {
|
|
259
|
+
await sendMessage({
|
|
260
|
+
messages: [{ role: "user", content: "Hello!" }],
|
|
261
|
+
model: "openai/gpt-4o",
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Authentication
|
|
268
|
+
|
|
269
|
+
Use `@privy-io/expo` for authentication in React Native:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import { PrivyProvider, usePrivy } from "@privy-io/expo";
|
|
273
|
+
import { useIdentityToken } from "@privy-io/expo";
|
|
274
|
+
|
|
275
|
+
// Wrap your app with PrivyProvider
|
|
276
|
+
<PrivyProvider appId="your-app-id" clientId="your-client-id">
|
|
277
|
+
<App />
|
|
278
|
+
</PrivyProvider>;
|
|
279
|
+
|
|
280
|
+
// Get identity token for API calls
|
|
281
|
+
const { getIdentityToken } = useIdentityToken();
|
|
282
|
+
```
|
|
283
|
+
|
|
180
284
|
## Contributing
|
|
181
285
|
|
|
182
286
|
Contributions are welcome! Please feel free to submit a pull request.
|
package/dist/index.d.mts
CHANGED
|
@@ -40,11 +40,11 @@ type LlmapiChatCompletionRequest = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Messages is the conversation history
|
|
42
42
|
*/
|
|
43
|
-
messages
|
|
43
|
+
messages: Array<LlmapiMessage>;
|
|
44
44
|
/**
|
|
45
45
|
* Model is the model identifier
|
|
46
46
|
*/
|
|
47
|
-
model
|
|
47
|
+
model: string;
|
|
48
48
|
/**
|
|
49
49
|
* Stream indicates if response should be streamed
|
|
50
50
|
*/
|
|
@@ -149,11 +149,11 @@ type LlmapiEmbeddingRequest = {
|
|
|
149
149
|
/**
|
|
150
150
|
* Input text or tokens to embed (can be string, []string, []int, or [][]int)
|
|
151
151
|
*/
|
|
152
|
-
input
|
|
152
|
+
input: unknown;
|
|
153
153
|
/**
|
|
154
154
|
* Model identifier in 'provider/model' format
|
|
155
155
|
*/
|
|
156
|
-
model
|
|
156
|
+
model: string;
|
|
157
157
|
};
|
|
158
158
|
type LlmapiEmbeddingResponse = {
|
|
159
159
|
/**
|
|
@@ -219,11 +219,11 @@ type LlmapiImageGenerationRequest = {
|
|
|
219
219
|
/**
|
|
220
220
|
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
221
221
|
*/
|
|
222
|
-
model
|
|
222
|
+
model: string;
|
|
223
223
|
/**
|
|
224
224
|
* Prompt is the text description of the desired image.
|
|
225
225
|
*/
|
|
226
|
-
prompt
|
|
226
|
+
prompt: string;
|
|
227
227
|
/**
|
|
228
228
|
* Quality targets a quality preset (e.g., "auto", "high").
|
|
229
229
|
*/
|
|
@@ -466,7 +466,7 @@ type LlmapiSearchRequest = {
|
|
|
466
466
|
/**
|
|
467
467
|
* Search query. Can be a single string or array of strings.
|
|
468
468
|
*/
|
|
469
|
-
query
|
|
469
|
+
query: Array<string>;
|
|
470
470
|
/**
|
|
471
471
|
* List of domains to filter results (max 20 domains).
|
|
472
472
|
*/
|
|
@@ -474,7 +474,7 @@ type LlmapiSearchRequest = {
|
|
|
474
474
|
/**
|
|
475
475
|
* The search provider to use.
|
|
476
476
|
*/
|
|
477
|
-
search_tool_name
|
|
477
|
+
search_tool_name: string;
|
|
478
478
|
};
|
|
479
479
|
type LlmapiSearchResponse = {
|
|
480
480
|
extra_fields?: LlmapiSearchExtraFields;
|
package/dist/index.d.ts
CHANGED
|
@@ -40,11 +40,11 @@ type LlmapiChatCompletionRequest = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Messages is the conversation history
|
|
42
42
|
*/
|
|
43
|
-
messages
|
|
43
|
+
messages: Array<LlmapiMessage>;
|
|
44
44
|
/**
|
|
45
45
|
* Model is the model identifier
|
|
46
46
|
*/
|
|
47
|
-
model
|
|
47
|
+
model: string;
|
|
48
48
|
/**
|
|
49
49
|
* Stream indicates if response should be streamed
|
|
50
50
|
*/
|
|
@@ -149,11 +149,11 @@ type LlmapiEmbeddingRequest = {
|
|
|
149
149
|
/**
|
|
150
150
|
* Input text or tokens to embed (can be string, []string, []int, or [][]int)
|
|
151
151
|
*/
|
|
152
|
-
input
|
|
152
|
+
input: unknown;
|
|
153
153
|
/**
|
|
154
154
|
* Model identifier in 'provider/model' format
|
|
155
155
|
*/
|
|
156
|
-
model
|
|
156
|
+
model: string;
|
|
157
157
|
};
|
|
158
158
|
type LlmapiEmbeddingResponse = {
|
|
159
159
|
/**
|
|
@@ -219,11 +219,11 @@ type LlmapiImageGenerationRequest = {
|
|
|
219
219
|
/**
|
|
220
220
|
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
221
221
|
*/
|
|
222
|
-
model
|
|
222
|
+
model: string;
|
|
223
223
|
/**
|
|
224
224
|
* Prompt is the text description of the desired image.
|
|
225
225
|
*/
|
|
226
|
-
prompt
|
|
226
|
+
prompt: string;
|
|
227
227
|
/**
|
|
228
228
|
* Quality targets a quality preset (e.g., "auto", "high").
|
|
229
229
|
*/
|
|
@@ -466,7 +466,7 @@ type LlmapiSearchRequest = {
|
|
|
466
466
|
/**
|
|
467
467
|
* Search query. Can be a single string or array of strings.
|
|
468
468
|
*/
|
|
469
|
-
query
|
|
469
|
+
query: Array<string>;
|
|
470
470
|
/**
|
|
471
471
|
* List of domains to filter results (max 20 domains).
|
|
472
472
|
*/
|
|
@@ -474,7 +474,7 @@ type LlmapiSearchRequest = {
|
|
|
474
474
|
/**
|
|
475
475
|
* The search provider to use.
|
|
476
476
|
*/
|
|
477
|
-
search_tool_name
|
|
477
|
+
search_tool_name: string;
|
|
478
478
|
};
|
|
479
479
|
type LlmapiSearchResponse = {
|
|
480
480
|
extra_fields?: LlmapiSearchExtraFields;
|
package/dist/react/index.cjs
CHANGED
|
@@ -49065,7 +49065,7 @@ var generateEmbeddingForText = async (text, options = {}) => {
|
|
|
49065
49065
|
baseUrl,
|
|
49066
49066
|
body: {
|
|
49067
49067
|
input: text,
|
|
49068
|
-
model: model2
|
|
49068
|
+
model: model2 ?? DEFAULT_API_EMBEDDING_MODEL
|
|
49069
49069
|
},
|
|
49070
49070
|
headers: {
|
|
49071
49071
|
Authorization: `Bearer ${token}`
|
package/dist/react/index.d.mts
CHANGED
|
@@ -98,11 +98,11 @@ type LlmapiImageGenerationRequest = {
|
|
|
98
98
|
/**
|
|
99
99
|
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
100
100
|
*/
|
|
101
|
-
model
|
|
101
|
+
model: string;
|
|
102
102
|
/**
|
|
103
103
|
* Prompt is the text description of the desired image.
|
|
104
104
|
*/
|
|
105
|
-
prompt
|
|
105
|
+
prompt: string;
|
|
106
106
|
/**
|
|
107
107
|
* Quality targets a quality preset (e.g., "auto", "high").
|
|
108
108
|
*/
|
|
@@ -301,32 +301,6 @@ type LlmapiSearchExtraFields = {
|
|
|
301
301
|
*/
|
|
302
302
|
search_provider?: string;
|
|
303
303
|
};
|
|
304
|
-
type LlmapiSearchRequest = {
|
|
305
|
-
/**
|
|
306
|
-
* Country code filter (e.g., "US", "GB", "DE").
|
|
307
|
-
*/
|
|
308
|
-
country?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Maximum number of results to return (1-20). Default: 10.
|
|
311
|
-
*/
|
|
312
|
-
max_results?: number;
|
|
313
|
-
/**
|
|
314
|
-
* Maximum tokens per page to process. Default: 1024.
|
|
315
|
-
*/
|
|
316
|
-
max_tokens_per_page?: number;
|
|
317
|
-
/**
|
|
318
|
-
* Search query. Can be a single string or array of strings.
|
|
319
|
-
*/
|
|
320
|
-
query?: Array<string>;
|
|
321
|
-
/**
|
|
322
|
-
* List of domains to filter results (max 20 domains).
|
|
323
|
-
*/
|
|
324
|
-
search_domain_filter?: Array<string>;
|
|
325
|
-
/**
|
|
326
|
-
* The search provider to use.
|
|
327
|
-
*/
|
|
328
|
-
search_tool_name?: string;
|
|
329
|
-
};
|
|
330
304
|
type LlmapiSearchResponse = {
|
|
331
305
|
extra_fields?: LlmapiSearchExtraFields;
|
|
332
306
|
/**
|
|
@@ -777,7 +751,28 @@ type UseSearchOptions = {
|
|
|
777
751
|
*/
|
|
778
752
|
onError?: (error: Error) => void;
|
|
779
753
|
};
|
|
780
|
-
type SearchOptions =
|
|
754
|
+
type SearchOptions = {
|
|
755
|
+
/**
|
|
756
|
+
* Country code for search results (e.g., "us", "gb")
|
|
757
|
+
*/
|
|
758
|
+
country?: string;
|
|
759
|
+
/**
|
|
760
|
+
* Maximum number of results to return
|
|
761
|
+
*/
|
|
762
|
+
max_results?: number;
|
|
763
|
+
/**
|
|
764
|
+
* Maximum tokens per page
|
|
765
|
+
*/
|
|
766
|
+
max_tokens_per_page?: number;
|
|
767
|
+
/**
|
|
768
|
+
* List of domains to filter results (max 20 domains)
|
|
769
|
+
*/
|
|
770
|
+
search_domain_filter?: string[];
|
|
771
|
+
/**
|
|
772
|
+
* The search provider to use
|
|
773
|
+
*/
|
|
774
|
+
search_tool_name?: string;
|
|
775
|
+
};
|
|
781
776
|
type UseSearchResult = {
|
|
782
777
|
isLoading: boolean;
|
|
783
778
|
search: (query: string | string[], options?: SearchOptions) => Promise<LlmapiSearchResponse | null>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -98,11 +98,11 @@ type LlmapiImageGenerationRequest = {
|
|
|
98
98
|
/**
|
|
99
99
|
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
100
100
|
*/
|
|
101
|
-
model
|
|
101
|
+
model: string;
|
|
102
102
|
/**
|
|
103
103
|
* Prompt is the text description of the desired image.
|
|
104
104
|
*/
|
|
105
|
-
prompt
|
|
105
|
+
prompt: string;
|
|
106
106
|
/**
|
|
107
107
|
* Quality targets a quality preset (e.g., "auto", "high").
|
|
108
108
|
*/
|
|
@@ -301,32 +301,6 @@ type LlmapiSearchExtraFields = {
|
|
|
301
301
|
*/
|
|
302
302
|
search_provider?: string;
|
|
303
303
|
};
|
|
304
|
-
type LlmapiSearchRequest = {
|
|
305
|
-
/**
|
|
306
|
-
* Country code filter (e.g., "US", "GB", "DE").
|
|
307
|
-
*/
|
|
308
|
-
country?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Maximum number of results to return (1-20). Default: 10.
|
|
311
|
-
*/
|
|
312
|
-
max_results?: number;
|
|
313
|
-
/**
|
|
314
|
-
* Maximum tokens per page to process. Default: 1024.
|
|
315
|
-
*/
|
|
316
|
-
max_tokens_per_page?: number;
|
|
317
|
-
/**
|
|
318
|
-
* Search query. Can be a single string or array of strings.
|
|
319
|
-
*/
|
|
320
|
-
query?: Array<string>;
|
|
321
|
-
/**
|
|
322
|
-
* List of domains to filter results (max 20 domains).
|
|
323
|
-
*/
|
|
324
|
-
search_domain_filter?: Array<string>;
|
|
325
|
-
/**
|
|
326
|
-
* The search provider to use.
|
|
327
|
-
*/
|
|
328
|
-
search_tool_name?: string;
|
|
329
|
-
};
|
|
330
304
|
type LlmapiSearchResponse = {
|
|
331
305
|
extra_fields?: LlmapiSearchExtraFields;
|
|
332
306
|
/**
|
|
@@ -777,7 +751,28 @@ type UseSearchOptions = {
|
|
|
777
751
|
*/
|
|
778
752
|
onError?: (error: Error) => void;
|
|
779
753
|
};
|
|
780
|
-
type SearchOptions =
|
|
754
|
+
type SearchOptions = {
|
|
755
|
+
/**
|
|
756
|
+
* Country code for search results (e.g., "us", "gb")
|
|
757
|
+
*/
|
|
758
|
+
country?: string;
|
|
759
|
+
/**
|
|
760
|
+
* Maximum number of results to return
|
|
761
|
+
*/
|
|
762
|
+
max_results?: number;
|
|
763
|
+
/**
|
|
764
|
+
* Maximum tokens per page
|
|
765
|
+
*/
|
|
766
|
+
max_tokens_per_page?: number;
|
|
767
|
+
/**
|
|
768
|
+
* List of domains to filter results (max 20 domains)
|
|
769
|
+
*/
|
|
770
|
+
search_domain_filter?: string[];
|
|
771
|
+
/**
|
|
772
|
+
* The search provider to use
|
|
773
|
+
*/
|
|
774
|
+
search_tool_name?: string;
|
|
775
|
+
};
|
|
781
776
|
type UseSearchResult = {
|
|
782
777
|
isLoading: boolean;
|
|
783
778
|
search: (query: string | string[], options?: SearchOptions) => Promise<LlmapiSearchResponse | null>;
|
package/dist/react/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reverbia/sdk",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.20251208112742",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"homepage": "https://github.com/zeta-chain/ai-sdk#readme",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@huggingface/transformers": "^3.8.0",
|
|
75
|
-
"@reverbia/portal": "1.0.0-next.
|
|
75
|
+
"@reverbia/portal": "1.0.0-next.20251208093751",
|
|
76
76
|
"ai": "5.0.93",
|
|
77
77
|
"pdfjs-dist": "^4.10.38",
|
|
78
78
|
"tesseract.js": "^6.0.1"
|