@reverbia/sdk 1.0.0-next.20260111202106 → 1.0.0-next.20260112105133
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/dist/expo/index.cjs +35 -130
- package/dist/expo/index.d.mts +1 -131
- package/dist/expo/index.d.ts +1 -131
- package/dist/expo/index.mjs +32 -126
- package/dist/index.cjs +12 -28
- package/dist/index.d.mts +54 -254
- package/dist/index.d.ts +54 -254
- package/dist/index.mjs +12 -26
- package/dist/react/index.cjs +81 -272
- package/dist/react/index.d.mts +1 -245
- package/dist/react/index.d.ts +1 -245
- package/dist/react/index.mjs +71 -260
- package/package.json +2 -2
package/dist/expo/index.mjs
CHANGED
|
@@ -2087,7 +2087,7 @@ function useChatStorage(options) {
|
|
|
2087
2087
|
};
|
|
2088
2088
|
}
|
|
2089
2089
|
|
|
2090
|
-
// src/react/
|
|
2090
|
+
// src/react/useModels.ts
|
|
2091
2091
|
import { useCallback as useCallback3, useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
|
|
2092
2092
|
|
|
2093
2093
|
// src/client/core/bodySerializer.gen.ts
|
|
@@ -2899,16 +2899,6 @@ var createClient = (config = {}) => {
|
|
|
2899
2899
|
var client = createClient(createClientConfig(createConfig()));
|
|
2900
2900
|
|
|
2901
2901
|
// src/client/sdk.gen.ts
|
|
2902
|
-
var postApiV1ImagesGenerations = (options) => {
|
|
2903
|
-
return (options.client ?? client).post({
|
|
2904
|
-
url: "/api/v1/images/generations",
|
|
2905
|
-
...options,
|
|
2906
|
-
headers: {
|
|
2907
|
-
"Content-Type": "application/json",
|
|
2908
|
-
...options.headers
|
|
2909
|
-
}
|
|
2910
|
-
});
|
|
2911
|
-
};
|
|
2912
2902
|
var getApiV1Models = (options) => {
|
|
2913
2903
|
return (options?.client ?? client).get({
|
|
2914
2904
|
url: "/api/v1/models",
|
|
@@ -2916,104 +2906,22 @@ var getApiV1Models = (options) => {
|
|
|
2916
2906
|
});
|
|
2917
2907
|
};
|
|
2918
2908
|
|
|
2919
|
-
// src/react/useImageGeneration.ts
|
|
2920
|
-
function useImageGeneration(options = {}) {
|
|
2921
|
-
const { getToken, baseUrl = BASE_URL, onFinish, onError } = options;
|
|
2922
|
-
const [isLoading, setIsLoading] = useState3(false);
|
|
2923
|
-
const abortControllerRef = useRef2(null);
|
|
2924
|
-
useEffect2(() => {
|
|
2925
|
-
return () => {
|
|
2926
|
-
if (abortControllerRef.current) {
|
|
2927
|
-
abortControllerRef.current.abort();
|
|
2928
|
-
abortControllerRef.current = null;
|
|
2929
|
-
}
|
|
2930
|
-
};
|
|
2931
|
-
}, []);
|
|
2932
|
-
const stop = useCallback3(() => {
|
|
2933
|
-
if (abortControllerRef.current) {
|
|
2934
|
-
abortControllerRef.current.abort();
|
|
2935
|
-
abortControllerRef.current = null;
|
|
2936
|
-
}
|
|
2937
|
-
}, []);
|
|
2938
|
-
const generateImage = useCallback3(
|
|
2939
|
-
async (args) => {
|
|
2940
|
-
if (abortControllerRef.current) {
|
|
2941
|
-
abortControllerRef.current.abort();
|
|
2942
|
-
}
|
|
2943
|
-
const abortController = new AbortController();
|
|
2944
|
-
abortControllerRef.current = abortController;
|
|
2945
|
-
setIsLoading(true);
|
|
2946
|
-
try {
|
|
2947
|
-
if (!getToken) {
|
|
2948
|
-
throw new Error("Token getter function is required.");
|
|
2949
|
-
}
|
|
2950
|
-
const token = await getToken();
|
|
2951
|
-
if (!token) {
|
|
2952
|
-
throw new Error("No access token available.");
|
|
2953
|
-
}
|
|
2954
|
-
const response = await postApiV1ImagesGenerations({
|
|
2955
|
-
baseUrl,
|
|
2956
|
-
body: args,
|
|
2957
|
-
headers: {
|
|
2958
|
-
Authorization: `Bearer ${token}`
|
|
2959
|
-
},
|
|
2960
|
-
signal: abortController.signal
|
|
2961
|
-
});
|
|
2962
|
-
if (response.error) {
|
|
2963
|
-
const errorMsg = response.error.error || "Failed to generate image";
|
|
2964
|
-
throw new Error(errorMsg);
|
|
2965
|
-
}
|
|
2966
|
-
if (!response.data) {
|
|
2967
|
-
throw new Error("No data received from image generation API");
|
|
2968
|
-
}
|
|
2969
|
-
const result = response.data;
|
|
2970
|
-
if (onFinish) {
|
|
2971
|
-
onFinish(result);
|
|
2972
|
-
}
|
|
2973
|
-
return { data: result, error: null };
|
|
2974
|
-
} catch (err) {
|
|
2975
|
-
if (err instanceof Error && err.name === "AbortError") {
|
|
2976
|
-
return { data: null, error: "Request aborted" };
|
|
2977
|
-
}
|
|
2978
|
-
const errorMsg = err instanceof Error ? err.message : "Failed to generate image.";
|
|
2979
|
-
const errorObj = err instanceof Error ? err : new Error(errorMsg);
|
|
2980
|
-
if (onError) {
|
|
2981
|
-
onError(errorObj);
|
|
2982
|
-
}
|
|
2983
|
-
return { data: null, error: errorMsg };
|
|
2984
|
-
} finally {
|
|
2985
|
-
if (abortControllerRef.current === abortController) {
|
|
2986
|
-
setIsLoading(false);
|
|
2987
|
-
abortControllerRef.current = null;
|
|
2988
|
-
}
|
|
2989
|
-
}
|
|
2990
|
-
},
|
|
2991
|
-
[getToken, baseUrl, onFinish, onError]
|
|
2992
|
-
);
|
|
2993
|
-
return {
|
|
2994
|
-
isLoading,
|
|
2995
|
-
generateImage,
|
|
2996
|
-
stop
|
|
2997
|
-
};
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
2909
|
// src/react/useModels.ts
|
|
3001
|
-
import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
3002
2910
|
function useModels(options = {}) {
|
|
3003
2911
|
const { getToken, baseUrl = BASE_URL, provider, autoFetch = true } = options;
|
|
3004
|
-
const [models, setModels] =
|
|
3005
|
-
const [isLoading, setIsLoading] =
|
|
3006
|
-
const [error, setError] =
|
|
3007
|
-
const getTokenRef =
|
|
3008
|
-
const baseUrlRef =
|
|
3009
|
-
const providerRef =
|
|
3010
|
-
const abortControllerRef =
|
|
3011
|
-
|
|
2912
|
+
const [models, setModels] = useState3([]);
|
|
2913
|
+
const [isLoading, setIsLoading] = useState3(false);
|
|
2914
|
+
const [error, setError] = useState3(null);
|
|
2915
|
+
const getTokenRef = useRef2(getToken);
|
|
2916
|
+
const baseUrlRef = useRef2(baseUrl);
|
|
2917
|
+
const providerRef = useRef2(provider);
|
|
2918
|
+
const abortControllerRef = useRef2(null);
|
|
2919
|
+
useEffect2(() => {
|
|
3012
2920
|
getTokenRef.current = getToken;
|
|
3013
2921
|
baseUrlRef.current = baseUrl;
|
|
3014
2922
|
providerRef.current = provider;
|
|
3015
2923
|
});
|
|
3016
|
-
|
|
2924
|
+
useEffect2(() => {
|
|
3017
2925
|
return () => {
|
|
3018
2926
|
if (abortControllerRef.current) {
|
|
3019
2927
|
abortControllerRef.current.abort();
|
|
@@ -3021,7 +2929,7 @@ function useModels(options = {}) {
|
|
|
3021
2929
|
}
|
|
3022
2930
|
};
|
|
3023
2931
|
}, []);
|
|
3024
|
-
const fetchModels =
|
|
2932
|
+
const fetchModels = useCallback3(async () => {
|
|
3025
2933
|
if (abortControllerRef.current) {
|
|
3026
2934
|
abortControllerRef.current.abort();
|
|
3027
2935
|
}
|
|
@@ -3079,12 +2987,12 @@ function useModels(options = {}) {
|
|
|
3079
2987
|
}
|
|
3080
2988
|
}
|
|
3081
2989
|
}, []);
|
|
3082
|
-
const refetch =
|
|
2990
|
+
const refetch = useCallback3(async () => {
|
|
3083
2991
|
setModels([]);
|
|
3084
2992
|
await fetchModels();
|
|
3085
2993
|
}, [fetchModels]);
|
|
3086
|
-
const hasFetchedRef =
|
|
3087
|
-
|
|
2994
|
+
const hasFetchedRef = useRef2(false);
|
|
2995
|
+
useEffect2(() => {
|
|
3088
2996
|
if (autoFetch && !hasFetchedRef.current) {
|
|
3089
2997
|
hasFetchedRef.current = true;
|
|
3090
2998
|
fetchModels();
|
|
@@ -3102,7 +3010,7 @@ function useModels(options = {}) {
|
|
|
3102
3010
|
}
|
|
3103
3011
|
|
|
3104
3012
|
// src/expo/useMemoryStorage.ts
|
|
3105
|
-
import { useCallback as
|
|
3013
|
+
import { useCallback as useCallback4, useState as useState4, useMemo as useMemo2, useRef as useRef3 } from "react";
|
|
3106
3014
|
import { postApiV1ChatCompletions } from "@reverbia/sdk";
|
|
3107
3015
|
|
|
3108
3016
|
// src/lib/db/memory/schema.ts
|
|
@@ -3982,8 +3890,8 @@ function useMemoryStorage(options) {
|
|
|
3982
3890
|
baseUrl = BASE_URL
|
|
3983
3891
|
} = options;
|
|
3984
3892
|
const embeddingModel = userEmbeddingModel === void 0 ? DEFAULT_API_EMBEDDING_MODEL : userEmbeddingModel;
|
|
3985
|
-
const [memories, setMemories] =
|
|
3986
|
-
const extractionInProgressRef =
|
|
3893
|
+
const [memories, setMemories] = useState4([]);
|
|
3894
|
+
const extractionInProgressRef = useRef3(false);
|
|
3987
3895
|
const memoriesCollection = useMemo2(
|
|
3988
3896
|
() => database.get("memories"),
|
|
3989
3897
|
[database]
|
|
@@ -4012,11 +3920,11 @@ function useMemoryStorage(options) {
|
|
|
4012
3920
|
}),
|
|
4013
3921
|
[embeddingModel, getToken, baseUrl]
|
|
4014
3922
|
);
|
|
4015
|
-
const refreshMemories =
|
|
3923
|
+
const refreshMemories = useCallback4(async () => {
|
|
4016
3924
|
const storedMemories = await getAllMemoriesOp(storageCtx);
|
|
4017
3925
|
setMemories(storedMemories);
|
|
4018
3926
|
}, [storageCtx]);
|
|
4019
|
-
const extractMemoriesFromMessage =
|
|
3927
|
+
const extractMemoriesFromMessage = useCallback4(
|
|
4020
3928
|
async (opts) => {
|
|
4021
3929
|
const { messages, model } = opts;
|
|
4022
3930
|
if (!getToken || extractionInProgressRef.current) {
|
|
@@ -4042,8 +3950,7 @@ function useMemoryStorage(options) {
|
|
|
4042
3950
|
content: [{ type: "text", text: m.content }]
|
|
4043
3951
|
}))
|
|
4044
3952
|
],
|
|
4045
|
-
model: model || completionsModel
|
|
4046
|
-
tool_choice: "none"
|
|
3953
|
+
model: model || completionsModel
|
|
4047
3954
|
},
|
|
4048
3955
|
headers: {
|
|
4049
3956
|
Authorization: `Bearer ${token}`
|
|
@@ -4196,7 +4103,7 @@ function useMemoryStorage(options) {
|
|
|
4196
4103
|
refreshMemories
|
|
4197
4104
|
]
|
|
4198
4105
|
);
|
|
4199
|
-
const searchMemories =
|
|
4106
|
+
const searchMemories = useCallback4(
|
|
4200
4107
|
async (query, limit = 10, minSimilarity = 0.6) => {
|
|
4201
4108
|
if (!embeddingModel) {
|
|
4202
4109
|
console.warn("Cannot search memories: embeddingModel not provided");
|
|
@@ -4229,7 +4136,7 @@ function useMemoryStorage(options) {
|
|
|
4229
4136
|
},
|
|
4230
4137
|
[embeddingModel, embeddingOptions, storageCtx]
|
|
4231
4138
|
);
|
|
4232
|
-
const fetchAllMemories =
|
|
4139
|
+
const fetchAllMemories = useCallback4(async () => {
|
|
4233
4140
|
try {
|
|
4234
4141
|
return await getAllMemoriesOp(storageCtx);
|
|
4235
4142
|
} catch (error) {
|
|
@@ -4238,7 +4145,7 @@ function useMemoryStorage(options) {
|
|
|
4238
4145
|
);
|
|
4239
4146
|
}
|
|
4240
4147
|
}, [storageCtx]);
|
|
4241
|
-
const fetchMemoriesByNamespace =
|
|
4148
|
+
const fetchMemoriesByNamespace = useCallback4(
|
|
4242
4149
|
async (namespace) => {
|
|
4243
4150
|
if (!namespace) {
|
|
4244
4151
|
throw new Error("Missing required field: namespace");
|
|
@@ -4253,7 +4160,7 @@ function useMemoryStorage(options) {
|
|
|
4253
4160
|
},
|
|
4254
4161
|
[storageCtx]
|
|
4255
4162
|
);
|
|
4256
|
-
const fetchMemoriesByKey =
|
|
4163
|
+
const fetchMemoriesByKey = useCallback4(
|
|
4257
4164
|
async (namespace, key) => {
|
|
4258
4165
|
if (!namespace || !key) {
|
|
4259
4166
|
throw new Error("Missing required fields: namespace, key");
|
|
@@ -4268,7 +4175,7 @@ function useMemoryStorage(options) {
|
|
|
4268
4175
|
},
|
|
4269
4176
|
[storageCtx]
|
|
4270
4177
|
);
|
|
4271
|
-
const getMemoryById =
|
|
4178
|
+
const getMemoryById = useCallback4(
|
|
4272
4179
|
async (id) => {
|
|
4273
4180
|
try {
|
|
4274
4181
|
return await getMemoryByIdOp(storageCtx, id);
|
|
@@ -4280,7 +4187,7 @@ function useMemoryStorage(options) {
|
|
|
4280
4187
|
},
|
|
4281
4188
|
[storageCtx]
|
|
4282
4189
|
);
|
|
4283
|
-
const saveMemory =
|
|
4190
|
+
const saveMemory = useCallback4(
|
|
4284
4191
|
async (memory) => {
|
|
4285
4192
|
try {
|
|
4286
4193
|
const memoryToSave = { ...memory };
|
|
@@ -4322,7 +4229,7 @@ function useMemoryStorage(options) {
|
|
|
4322
4229
|
},
|
|
4323
4230
|
[storageCtx, generateEmbeddings, embeddingModel, embeddingOptions]
|
|
4324
4231
|
);
|
|
4325
|
-
const saveMemories =
|
|
4232
|
+
const saveMemories = useCallback4(
|
|
4326
4233
|
async (memoriesToSave) => {
|
|
4327
4234
|
try {
|
|
4328
4235
|
const memoriesWithEmbeddings = await Promise.all(
|
|
@@ -4366,7 +4273,7 @@ function useMemoryStorage(options) {
|
|
|
4366
4273
|
},
|
|
4367
4274
|
[storageCtx, generateEmbeddings, embeddingModel, embeddingOptions, refreshMemories]
|
|
4368
4275
|
);
|
|
4369
|
-
const updateMemory =
|
|
4276
|
+
const updateMemory = useCallback4(
|
|
4370
4277
|
async (id, updates) => {
|
|
4371
4278
|
const result = await updateMemoryOp(storageCtx, id, updates);
|
|
4372
4279
|
if (!result.ok) {
|
|
@@ -4409,7 +4316,7 @@ function useMemoryStorage(options) {
|
|
|
4409
4316
|
},
|
|
4410
4317
|
[storageCtx, generateEmbeddings, embeddingModel, embeddingOptions]
|
|
4411
4318
|
);
|
|
4412
|
-
const removeMemory =
|
|
4319
|
+
const removeMemory = useCallback4(
|
|
4413
4320
|
async (namespace, key, value) => {
|
|
4414
4321
|
if (!namespace || !key || !value) {
|
|
4415
4322
|
throw new Error("Missing required fields: namespace, key, value");
|
|
@@ -4429,7 +4336,7 @@ function useMemoryStorage(options) {
|
|
|
4429
4336
|
},
|
|
4430
4337
|
[storageCtx]
|
|
4431
4338
|
);
|
|
4432
|
-
const removeMemoryById =
|
|
4339
|
+
const removeMemoryById = useCallback4(
|
|
4433
4340
|
async (id) => {
|
|
4434
4341
|
try {
|
|
4435
4342
|
await deleteMemoryByIdOp(storageCtx, id);
|
|
@@ -4442,7 +4349,7 @@ function useMemoryStorage(options) {
|
|
|
4442
4349
|
},
|
|
4443
4350
|
[storageCtx]
|
|
4444
4351
|
);
|
|
4445
|
-
const removeMemories =
|
|
4352
|
+
const removeMemories = useCallback4(
|
|
4446
4353
|
async (namespace, key) => {
|
|
4447
4354
|
if (!namespace || !key) {
|
|
4448
4355
|
throw new Error("Missing required fields: namespace, key");
|
|
@@ -4460,7 +4367,7 @@ function useMemoryStorage(options) {
|
|
|
4460
4367
|
},
|
|
4461
4368
|
[storageCtx]
|
|
4462
4369
|
);
|
|
4463
|
-
const clearMemories =
|
|
4370
|
+
const clearMemories = useCallback4(async () => {
|
|
4464
4371
|
try {
|
|
4465
4372
|
await clearAllMemoriesOp(storageCtx);
|
|
4466
4373
|
setMemories([]);
|
|
@@ -4730,7 +4637,6 @@ export {
|
|
|
4730
4637
|
sdkSchema,
|
|
4731
4638
|
useChat,
|
|
4732
4639
|
useChatStorage,
|
|
4733
|
-
useImageGeneration,
|
|
4734
4640
|
useMemoryStorage,
|
|
4735
4641
|
useModels
|
|
4736
4642
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -27,9 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
getHealth: () => getHealth,
|
|
28
28
|
postApiV1ChatCompletions: () => postApiV1ChatCompletions,
|
|
29
29
|
postApiV1Embeddings: () => postApiV1Embeddings,
|
|
30
|
-
postApiV1ImagesGenerations: () => postApiV1ImagesGenerations,
|
|
31
30
|
postApiV1Responses: () => postApiV1Responses,
|
|
32
|
-
postApiV1Search: () => postApiV1Search,
|
|
33
31
|
postApiV1SubscriptionsCancel: () => postApiV1SubscriptionsCancel,
|
|
34
32
|
postApiV1SubscriptionsCreateCheckoutSession: () => postApiV1SubscriptionsCreateCheckoutSession,
|
|
35
33
|
postApiV1SubscriptionsCustomerPortal: () => postApiV1SubscriptionsCustomerPortal,
|
|
@@ -889,16 +887,6 @@ var postApiV1Embeddings = (options) => {
|
|
|
889
887
|
}
|
|
890
888
|
});
|
|
891
889
|
};
|
|
892
|
-
var postApiV1ImagesGenerations = (options) => {
|
|
893
|
-
return (options.client ?? client).post({
|
|
894
|
-
url: "/api/v1/images/generations",
|
|
895
|
-
...options,
|
|
896
|
-
headers: {
|
|
897
|
-
"Content-Type": "application/json",
|
|
898
|
-
...options.headers
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
};
|
|
902
890
|
var getApiV1Models = (options) => {
|
|
903
891
|
return (options?.client ?? client).get({
|
|
904
892
|
url: "/api/v1/models",
|
|
@@ -915,16 +903,6 @@ var postApiV1Responses = (options) => {
|
|
|
915
903
|
}
|
|
916
904
|
});
|
|
917
905
|
};
|
|
918
|
-
var postApiV1Search = (options) => {
|
|
919
|
-
return (options.client ?? client).post({
|
|
920
|
-
url: "/api/v1/search",
|
|
921
|
-
...options,
|
|
922
|
-
headers: {
|
|
923
|
-
"Content-Type": "application/json",
|
|
924
|
-
...options.headers
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
};
|
|
928
906
|
var postApiV1SubscriptionsCancel = (options) => {
|
|
929
907
|
return (options?.client ?? client).post({
|
|
930
908
|
url: "/api/v1/subscriptions/cancel",
|
|
@@ -932,15 +910,23 @@ var postApiV1SubscriptionsCancel = (options) => {
|
|
|
932
910
|
});
|
|
933
911
|
};
|
|
934
912
|
var postApiV1SubscriptionsCreateCheckoutSession = (options) => {
|
|
935
|
-
return (options
|
|
913
|
+
return (options.client ?? client).post({
|
|
936
914
|
url: "/api/v1/subscriptions/create-checkout-session",
|
|
937
|
-
...options
|
|
915
|
+
...options,
|
|
916
|
+
headers: {
|
|
917
|
+
"Content-Type": "application/json",
|
|
918
|
+
...options.headers
|
|
919
|
+
}
|
|
938
920
|
});
|
|
939
921
|
};
|
|
940
922
|
var postApiV1SubscriptionsCustomerPortal = (options) => {
|
|
941
|
-
return (options
|
|
923
|
+
return (options.client ?? client).post({
|
|
942
924
|
url: "/api/v1/subscriptions/customer-portal",
|
|
943
|
-
...options
|
|
925
|
+
...options,
|
|
926
|
+
headers: {
|
|
927
|
+
"Content-Type": "application/json",
|
|
928
|
+
...options.headers
|
|
929
|
+
}
|
|
944
930
|
});
|
|
945
931
|
};
|
|
946
932
|
var postApiV1SubscriptionsRenew = (options) => {
|
|
@@ -1010,9 +996,7 @@ var getHealth = (options) => {
|
|
|
1010
996
|
getHealth,
|
|
1011
997
|
postApiV1ChatCompletions,
|
|
1012
998
|
postApiV1Embeddings,
|
|
1013
|
-
postApiV1ImagesGenerations,
|
|
1014
999
|
postApiV1Responses,
|
|
1015
|
-
postApiV1Search,
|
|
1016
1000
|
postApiV1SubscriptionsCancel,
|
|
1017
1001
|
postApiV1SubscriptionsCreateCheckoutSession,
|
|
1018
1002
|
postApiV1SubscriptionsCustomerPortal,
|