Skip to content

Commit 6378d6b

Browse files
refactor for react - tts is causing trouble - refactoring that now - will follow with flutter once done
1 parent 5ea8293 commit 6378d6b

32 files changed

Lines changed: 1577 additions & 1076 deletions

File tree

examples/react-native/RunAnywhereAI/App.tsx

Lines changed: 191 additions & 195 deletions
Large diffs are not rendered by default.

examples/react-native/RunAnywhereAI/ios/RunAnywhereAI.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
9E75FBBD9CE4CFEFC37E3C16 /* libPods-RunAnywhereAI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunAnywhereAI.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4949
AABB001122334456 /* NativeAudioModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NativeAudioModule.swift; path = RunAnywhereAI/NativeAudioModule.swift; sourceTree = "<group>"; };
5050
AABB001122334458 /* NativeAudioModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NativeAudioModule.m; path = RunAnywhereAI/NativeAudioModule.m; sourceTree = "<group>"; };
51+
AABB001122334459 /* RunAnywhereAI-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RunAnywhereAI-Bridging-Header.h"; path = "RunAnywhereAI/RunAnywhereAI-Bridging-Header.h"; sourceTree = "<group>"; };
5152
CCDD001122334456 /* DocumentService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DocumentService.swift; path = RunAnywhereAI/DocumentService.swift; sourceTree = "<group>"; };
5253
CCDD001122334458 /* DocumentService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DocumentService.m; path = RunAnywhereAI/DocumentService.m; sourceTree = "<group>"; };
53-
AABB001122334459 /* RunAnywhereAI-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "RunAnywhereAI-Bridging-Header.h"; path = "RunAnywhereAI/RunAnywhereAI-Bridging-Header.h"; sourceTree = "<group>"; };
5454
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
5555
FF375136ECCEFB06442E8E31 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = RunAnywhereAI/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
5656
/* End PBXFileReference section */

examples/react-native/RunAnywhereAI/src/components/model/ModelSelectionSheet.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,6 @@ export const ModelSelectionSheet: React.FC<ModelSelectionSheetProps> = ({
293293
if (!fw || !allowedFrameworks.has(fw)) return false;
294294
}
295295

296-
// Exclude supporting files (vocab, tokenizer) from embedding selection
297-
if (context === ModelSelectionContext.RagEmbedding) {
298-
const id = m.id.toLowerCase();
299-
if (id.endsWith('-vocab') || id.endsWith('-tokenizer')) return false;
300-
}
301-
302296
return true;
303297
})
304298
: allModels;

examples/react-native/RunAnywhereAI/src/screens/RAGScreen.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {
4444
ragDestroyPipeline,
4545
ragIngest,
4646
ragQuery,
47-
type RAGConfiguration,
4847
} from '@runanywhere/core';
4948

5049
// MARK: - Types
@@ -75,15 +74,6 @@ function resolveLLMFilePath(localPath: string): string {
7574
return localPath;
7675
}
7776

78-
function resolveVocabPath(embeddingPath: string): string | null {
79-
if (embeddingPath.endsWith('.onnx')) {
80-
const lastSlash = embeddingPath.lastIndexOf('/');
81-
if (lastSlash === -1) return null;
82-
return `${embeddingPath.substring(0, lastSlash)}/vocab.txt`;
83-
}
84-
return `${embeddingPath}/vocab.txt`;
85-
}
86-
8777
// MARK: - Document Text Extraction
8878

8979
const { DocumentService: NativeDocumentService } = NativeModules;
@@ -191,24 +181,22 @@ export const RAGScreen: React.FC = () => {
191181
// Extract text from the picked file
192182
const text = await extractTextFromFile(fileUri);
193183

194-
// Build RAG configuration matching iOS ragConfig computed property
184+
// Build RAG configuration matching iOS ragConfig computed property.
185+
// With multi-file registration, vocab.txt is co-located with model.onnx,
186+
// so the C++ pipeline auto-discovers it (no embeddingConfigJSON needed).
195187
const embeddingPath = resolveEmbeddingFilePath(
196188
selectedEmbeddingModel!.localPath!
197189
);
198190
const llmPath = resolveLLMFilePath(selectedLLMModel!.localPath!);
199-
const vocabPath = resolveVocabPath(embeddingPath);
200191

201-
const config: RAGConfiguration = {
192+
const config = {
202193
embeddingModelPath: embeddingPath,
203194
llmModelPath: llmPath,
204195
topK: 5,
205196
similarityThreshold: 0.25,
206197
maxContextTokens: 2048,
207198
chunkSize: 512,
208199
chunkOverlap: 50,
209-
embeddingConfigJSON: vocabPath
210-
? JSON.stringify({ vocab_path: vocabPath })
211-
: undefined,
212200
};
213201

214202
// Create pipeline and ingest document (same as iOS loadDocument)

sdk/runanywhere-commons/include/rac/features/embeddings/rac_embeddings_service.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ typedef struct rac_embeddings_service {
7474
*/
7575
RAC_API rac_result_t rac_embeddings_create(const char* model_id, rac_handle_t* out_handle);
7676

77+
/**
78+
* @brief Create an embeddings service with additional configuration JSON.
79+
*
80+
* Same as rac_embeddings_create but forwards config_json (e.g. {"vocab_path":"..."})
81+
* to the embedding provider so it can locate companion files.
82+
*
83+
* @param model_id Model identifier or path
84+
* @param config_json JSON string with provider-specific config (can be NULL)
85+
* @param out_handle Output: Service handle
86+
* @return RAC_SUCCESS or error code
87+
*/
88+
RAC_API rac_result_t rac_embeddings_create_with_config(const char* model_id,
89+
const char* config_json,
90+
rac_handle_t* out_handle);
91+
7792
/**
7893
* @brief Initialize the service with a model
7994
*

0 commit comments

Comments
 (0)