@functionland/react-native-fula 1.55.0 → 1.55.1
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/LICENSE +20 -20
- package/android/build.gradle +114 -115
- package/android/gradle.properties +8 -8
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -2
- package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
- package/android/src/main/java/land/fx/fula/Cryptography.java +62 -62
- package/android/src/main/java/land/fx/fula/FulaModule.java +1991 -1868
- package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
- package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
- package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
- package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
- package/ios/Cryptography.swift +59 -59
- package/ios/Fula-Bridging-Header.h +3 -3
- package/ios/UserDataHelper.swift +143 -143
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-consts.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-errors.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-events.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-query.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-rpc.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-runtime.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api-tx.js.map +1 -1
- package/lib/commonjs/interfaces/augment-api.js.map +1 -1
- package/lib/commonjs/interfaces/augment-types.js.map +1 -1
- package/lib/commonjs/interfaces/definitions.js.map +1 -1
- package/lib/commonjs/interfaces/defintions.js.map +1 -1
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/interfaces/index.js.map +1 -1
- package/lib/commonjs/interfaces/lookup.js +300 -300
- package/lib/commonjs/interfaces/lookup.js.map +1 -1
- package/lib/commonjs/interfaces/registry.js.map +1 -1
- package/lib/commonjs/interfaces/types-lookup.js.map +1 -1
- package/lib/commonjs/interfaces/types.js.map +1 -1
- package/lib/commonjs/protocols/blockchain.js +66 -66
- package/lib/commonjs/protocols/blockchain.js.map +1 -1
- package/lib/commonjs/protocols/chain-api.js.map +1 -1
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/commonjs/protocols/fx-ai.js +103 -0
- package/lib/commonjs/protocols/fx-ai.js.map +1 -0
- package/lib/commonjs/protocols/fxblox.js +3 -3
- package/lib/commonjs/protocols/fxblox.js.map +1 -1
- package/lib/commonjs/types/blockchain.js.map +1 -1
- package/lib/commonjs/types/fxblox.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces/augment-api-consts.js.map +1 -1
- package/lib/module/interfaces/augment-api-errors.js.map +1 -1
- package/lib/module/interfaces/augment-api-events.js.map +1 -1
- package/lib/module/interfaces/augment-api-query.js.map +1 -1
- package/lib/module/interfaces/augment-api-rpc.js.map +1 -1
- package/lib/module/interfaces/augment-api-runtime.js.map +1 -1
- package/lib/module/interfaces/augment-api-tx.js.map +1 -1
- package/lib/module/interfaces/augment-api.js.map +1 -1
- package/lib/module/interfaces/augment-types.js.map +1 -1
- package/lib/module/interfaces/definitions.js.map +1 -1
- package/lib/module/interfaces/defintions.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/interfaces/index.js.map +1 -1
- package/lib/module/interfaces/lookup.js +300 -300
- package/lib/module/interfaces/lookup.js.map +1 -1
- package/lib/module/interfaces/registry.js.map +1 -1
- package/lib/module/interfaces/types-lookup.js.map +1 -1
- package/lib/module/interfaces/types.js.map +1 -1
- package/lib/module/protocols/blockchain.js +66 -66
- package/lib/module/protocols/blockchain.js.map +1 -1
- package/lib/module/protocols/chain-api.js.map +1 -1
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/module/protocols/fx-ai.js +93 -0
- package/lib/module/protocols/fx-ai.js.map +1 -0
- package/lib/module/protocols/fxblox.js +3 -3
- package/lib/module/protocols/fxblox.js.map +1 -1
- package/lib/module/types/blockchain.js.map +1 -1
- package/lib/module/types/fxblox.js.map +1 -1
- package/package.json +176 -176
- package/react-native-fula.podspec +47 -47
- package/src/index.tsx +5 -4
- package/src/interfaces/augment-api-consts.ts +273 -273
- package/src/interfaces/augment-api-errors.ts +474 -474
- package/src/interfaces/augment-api-events.ts +448 -448
- package/src/interfaces/augment-api-query.ts +466 -466
- package/src/interfaces/augment-api-rpc.ts +617 -617
- package/src/interfaces/augment-api-runtime.ts +223 -223
- package/src/interfaces/augment-api-tx.ts +709 -709
- package/src/interfaces/augment-api.ts +9 -9
- package/src/interfaces/augment-types.ts +1322 -1322
- package/src/interfaces/definitions.ts +1 -1
- package/src/interfaces/defintions.ts +1 -1
- package/src/interfaces/fulaNativeModule.ts +175 -168
- package/src/interfaces/index.ts +3 -3
- package/src/interfaces/lookup.ts +2011 -2011
- package/src/interfaces/registry.ts +163 -163
- package/src/interfaces/types-lookup.ts +2165 -2165
- package/src/interfaces/types.ts +2 -2
- package/src/protocols/blockchain.ts +644 -644
- package/src/protocols/fx-ai.ts +111 -0
- package/src/protocols/fxblox.ts +443 -443
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import Fula from '../interfaces/fulaNativeModule';
|
|
2
|
+
import { DeviceEventEmitter } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export const chatWithAI = (
|
|
5
|
+
aiModel: string,
|
|
6
|
+
userMessage: string
|
|
7
|
+
): Promise<string> => {
|
|
8
|
+
console.log('chatWithAI in react-native started');
|
|
9
|
+
let res = Fula.chatWithAI(aiModel, userMessage)
|
|
10
|
+
.then((res1) => {
|
|
11
|
+
try {
|
|
12
|
+
return res1; // Return the stream ID directly
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.error('Error parsing res in chatWithAI:', e);
|
|
15
|
+
throw e; // Rethrow the error to maintain the rejection state
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
console.error('Error starting chat with AI:', err);
|
|
20
|
+
throw err; // Rethrow the error to maintain the rejection state
|
|
21
|
+
});
|
|
22
|
+
return res;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const getChatChunk = (streamID: string): Promise<string> => {
|
|
26
|
+
console.log('getChatChunk in react-native started');
|
|
27
|
+
let res = Fula.getChatChunk(streamID)
|
|
28
|
+
.then((res1) => {
|
|
29
|
+
try {
|
|
30
|
+
if (!res1 || res1.trim() === "") {
|
|
31
|
+
console.log('Empty chunk received.');
|
|
32
|
+
return ""; // Return an empty string for empty chunks
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log('Raw response from GetChatChunk:', res1); // Log raw response
|
|
36
|
+
|
|
37
|
+
const parsedChunk = JSON.parse(res1);
|
|
38
|
+
if (parsedChunk && parsedChunk.status && parsedChunk.msg) {
|
|
39
|
+
const content = parsedChunk.msg;
|
|
40
|
+
console.log('Processed content:', content); // Log processed content
|
|
41
|
+
return content;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return "";
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error('Error parsing res in getChatChunk:', e);
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
.catch((err) => {
|
|
51
|
+
console.error('Error getting chat chunk:', err);
|
|
52
|
+
throw err;
|
|
53
|
+
});
|
|
54
|
+
return res;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const fetchChunksUsingIterator = (streamID: string): Promise<string> => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
let fullResponse = '';
|
|
60
|
+
let active = true;
|
|
61
|
+
|
|
62
|
+
const cleanup = () => {
|
|
63
|
+
active = false;
|
|
64
|
+
DeviceEventEmitter.removeAllListeners('onChunkReceived');
|
|
65
|
+
DeviceEventEmitter.removeAllListeners('onStreamingCompleted');
|
|
66
|
+
DeviceEventEmitter.removeAllListeners('onStreamError');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const chunkHandler = (chunk: string) => {
|
|
70
|
+
if (active) fullResponse += chunk;
|
|
71
|
+
console.log('Chunk received:', chunk);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const completionHandler = () => {
|
|
75
|
+
if (active) {
|
|
76
|
+
cleanup();
|
|
77
|
+
resolve(fullResponse);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const errorHandler = (error: string) => {
|
|
82
|
+
if (active) {
|
|
83
|
+
cleanup();
|
|
84
|
+
if (error.includes('EOF')) {
|
|
85
|
+
// Treat EOF as successful completion
|
|
86
|
+
console.log('Stream completed with EOF');
|
|
87
|
+
resolve(fullResponse);
|
|
88
|
+
} else {
|
|
89
|
+
console.error('Stream error:', error);
|
|
90
|
+
reject(new Error(error || 'Unknown stream error'));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
DeviceEventEmitter.addListener('onChunkReceived', chunkHandler);
|
|
96
|
+
DeviceEventEmitter.addListener('onStreamingCompleted', completionHandler);
|
|
97
|
+
DeviceEventEmitter.addListener('onStreamError', errorHandler);
|
|
98
|
+
|
|
99
|
+
Fula.streamChunks(streamID)
|
|
100
|
+
.catch(error => {
|
|
101
|
+
if (active) {
|
|
102
|
+
cleanup();
|
|
103
|
+
if (error.message.includes('EOF')) {
|
|
104
|
+
resolve(fullResponse);
|
|
105
|
+
} else {
|
|
106
|
+
reject(error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|