Skip to content

Commit 59f96ff

Browse files
committed
vlm plus useafterfree fix ughhh
1 parent 27ae35f commit 59f96ff

12 files changed

Lines changed: 571 additions & 293 deletions

File tree

examples/flutter/RunAnywhereAI/lib/app/runanywhere_ai_app.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:runanywhere_ai/core/utilities/constants.dart';
1212
import 'package:runanywhere_ai/core/utilities/keychain_helper.dart';
1313
import 'package:runanywhere/public/extensions/rag_module.dart';
1414
import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart';
15+
import 'package:runanywhere_onnx/runanywhere_onnx.dart';
1516

1617
/// RunAnywhereAIApp (mirroring iOS RunAnywhereAIApp.swift)
1718
///
@@ -286,6 +287,14 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
286287
debugPrint('✅ ONNX Embedding models registered');
287288
await Future<void>.delayed(Duration.zero);
288289

290+
// --- ONNX BACKEND (required for embeddings used by RAG) ---
291+
try {
292+
await Onnx.register();
293+
debugPrint('✅ ONNX backend registered (STT + TTS + VAD + Embeddings)');
294+
} catch (e) {
295+
debugPrint('⚠️ ONNX backend not available: $e');
296+
}
297+
289298
// --- RAG BACKEND ---
290299
try {
291300
await RAGModule.register();

examples/flutter/RunAnywhereAI/lib/features/vision/vlm_view_model.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class VLMViewModel extends ChangeNotifier {
161161
final result = await sdk.RunAnywhere.processImageStream(
162162
image,
163163
prompt: 'Describe what you see briefly.',
164-
maxTokens: 200,
164+
options: const sdk.VLMGenerationOptions(maxTokens: 200),
165165
);
166166

167167
// Listen to stream and append tokens
@@ -201,7 +201,7 @@ class VLMViewModel extends ChangeNotifier {
201201
final result = await sdk.RunAnywhere.processImageStream(
202202
image,
203203
prompt: 'Describe this image in detail.',
204-
maxTokens: 300,
204+
options: const sdk.VLMGenerationOptions(maxTokens: 300),
205205
);
206206

207207
// Listen to stream and append tokens
@@ -285,7 +285,7 @@ class VLMViewModel extends ChangeNotifier {
285285
final result = await sdk.RunAnywhere.processImageStream(
286286
image,
287287
prompt: 'Describe what you see in one sentence.',
288-
maxTokens: 100,
288+
options: const sdk.VLMGenerationOptions(maxTokens: 100),
289289
);
290290

291291
// Listen to stream and build description

examples/flutter/RunAnywhereAI/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ dependencies:
1717
# RunAnywhere SDK - LlamaCpp Backend (LLM)
1818
runanywhere_llamacpp:
1919
path: ../../../sdk/runanywhere-flutter/packages/runanywhere_llamacpp
20+
21+
# RunAnywhere SDK - ONNX Backend (STT/TTS/VAD/Embeddings)
22+
runanywhere_onnx:
23+
path: ../../../sdk/runanywhere-flutter/packages/runanywhere_onnx
2024
provider: ^6.1.0
2125
flutter_markdown: ^0.6.18
2226
record: ^6.1.0

sdk/runanywhere-commons/include/rac/infrastructure/network/rac_auth_manager.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ typedef struct {
9696
* @brief Initialize auth manager
9797
* @param storage Secure storage callbacks (can be NULL for in-memory only)
9898
*/
99-
void rac_auth_init(const rac_secure_storage_t* storage);
99+
RAC_API void rac_auth_init(const rac_secure_storage_t* storage);
100100

101101
/**
102102
* @brief Reset auth manager state
103103
*/
104-
void rac_auth_reset(void);
104+
RAC_API void rac_auth_reset(void);
105105

106106
// =============================================================================
107107
// Token State
@@ -111,7 +111,7 @@ void rac_auth_reset(void);
111111
* @brief Check if currently authenticated
112112
* @return true if valid access token exists
113113
*/
114-
bool rac_auth_is_authenticated(void);
114+
RAC_API bool rac_auth_is_authenticated(void);
115115

116116
/**
117117
* @brief Check if token needs refresh
@@ -120,31 +120,31 @@ bool rac_auth_is_authenticated(void);
120120
*
121121
* @return true if token should be refreshed
122122
*/
123-
bool rac_auth_needs_refresh(void);
123+
RAC_API bool rac_auth_needs_refresh(void);
124124

125125
/**
126126
* @brief Get current access token
127127
* @return Access token string, or NULL if not authenticated
128128
*/
129-
const char* rac_auth_get_access_token(void);
129+
RAC_API const char* rac_auth_get_access_token(void);
130130

131131
/**
132132
* @brief Get current device ID
133133
* @return Device ID string, or NULL if not set
134134
*/
135-
const char* rac_auth_get_device_id(void);
135+
RAC_API const char* rac_auth_get_device_id(void);
136136

137137
/**
138138
* @brief Get current user ID
139139
* @return User ID string, or NULL if not set
140140
*/
141-
const char* rac_auth_get_user_id(void);
141+
RAC_API const char* rac_auth_get_user_id(void);
142142

143143
/**
144144
* @brief Get current organization ID
145145
* @return Organization ID string, or NULL if not set
146146
*/
147-
const char* rac_auth_get_organization_id(void);
147+
RAC_API const char* rac_auth_get_organization_id(void);
148148

149149
// =============================================================================
150150
// Request Building
@@ -158,7 +158,7 @@ const char* rac_auth_get_organization_id(void);
158158
* @param config SDK configuration with credentials
159159
* @return JSON string (caller must free), or NULL on error
160160
*/
161-
char* rac_auth_build_authenticate_request(const rac_sdk_config_t* config);
161+
RAC_API char* rac_auth_build_authenticate_request(const rac_sdk_config_t* config);
162162

163163
/**
164164
* @brief Build token refresh request JSON
@@ -167,7 +167,7 @@ char* rac_auth_build_authenticate_request(const rac_sdk_config_t* config);
167167
*
168168
* @return JSON string (caller must free), or NULL if no refresh token
169169
*/
170-
char* rac_auth_build_refresh_request(void);
170+
RAC_API char* rac_auth_build_refresh_request(void);
171171

172172
// =============================================================================
173173
// Response Handling
@@ -181,7 +181,7 @@ char* rac_auth_build_refresh_request(void);
181181
* @param json JSON response body
182182
* @return 0 on success, -1 on parse error
183183
*/
184-
int rac_auth_handle_authenticate_response(const char* json);
184+
RAC_API int rac_auth_handle_authenticate_response(const char* json);
185185

186186
/**
187187
* @brief Parse and store refresh response
@@ -191,7 +191,7 @@ int rac_auth_handle_authenticate_response(const char* json);
191191
* @param json JSON response body
192192
* @return 0 on success, -1 on parse error
193193
*/
194-
int rac_auth_handle_refresh_response(const char* json);
194+
RAC_API int rac_auth_handle_refresh_response(const char* json);
195195

196196
// =============================================================================
197197
// Token Management
@@ -214,14 +214,14 @@ int rac_auth_handle_refresh_response(const char* json);
214214
* @param out_needs_refresh Set to true if refresh HTTP call is needed
215215
* @return 0 on success (token valid), 1 if refresh needed, -1 on error
216216
*/
217-
int rac_auth_get_valid_token(const char** out_token, bool* out_needs_refresh);
217+
RAC_API int rac_auth_get_valid_token(const char** out_token, bool* out_needs_refresh);
218218

219219
/**
220220
* @brief Clear all authentication state
221221
*
222222
* Clears in-memory state and secure storage.
223223
*/
224-
void rac_auth_clear(void);
224+
RAC_API void rac_auth_clear(void);
225225

226226
// =============================================================================
227227
// Persistence
@@ -234,7 +234,7 @@ void rac_auth_clear(void);
234234
*
235235
* @return 0 on success (tokens loaded), -1 if not found or error
236236
*/
237-
int rac_auth_load_stored_tokens(void);
237+
RAC_API int rac_auth_load_stored_tokens(void);
238238

239239
/**
240240
* @brief Save current tokens to secure storage
@@ -243,7 +243,7 @@ int rac_auth_load_stored_tokens(void);
243243
*
244244
* @return 0 on success, -1 on error
245245
*/
246-
int rac_auth_save_tokens(void);
246+
RAC_API int rac_auth_save_tokens(void);
247247

248248
#ifdef __cplusplus
249249
}

sdk/runanywhere-commons/include/rac/infrastructure/network/rac_environment.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,56 +79,56 @@ typedef struct {
7979
* @param env The environment to check
8080
* @return true for staging/production, false for development
8181
*/
82-
bool rac_env_requires_auth(rac_environment_t env);
82+
RAC_API bool rac_env_requires_auth(rac_environment_t env);
8383

8484
/**
8585
* @brief Check if environment requires a backend URL
8686
* @param env The environment to check
8787
* @return true for staging/production, false for development
8888
*/
89-
bool rac_env_requires_backend_url(rac_environment_t env);
89+
RAC_API bool rac_env_requires_backend_url(rac_environment_t env);
9090

9191
/**
9292
* @brief Check if environment is production
9393
* @param env The environment to check
9494
* @return true only for production
9595
*/
96-
bool rac_env_is_production(rac_environment_t env);
96+
RAC_API bool rac_env_is_production(rac_environment_t env);
9797

9898
/**
9999
* @brief Check if environment is a testing environment
100100
* @param env The environment to check
101101
* @return true for development and staging
102102
*/
103-
bool rac_env_is_testing(rac_environment_t env);
103+
RAC_API bool rac_env_is_testing(rac_environment_t env);
104104

105105
/**
106106
* @brief Get the default log level for an environment
107107
* @param env The environment
108108
* @return DEBUG for development, INFO for staging, WARNING for production
109109
*/
110-
rac_log_level_t rac_env_default_log_level(rac_environment_t env);
110+
RAC_API rac_log_level_t rac_env_default_log_level(rac_environment_t env);
111111

112112
/**
113113
* @brief Check if telemetry should be sent for this environment
114114
* @param env The environment
115115
* @return true only for production
116116
*/
117-
bool rac_env_should_send_telemetry(rac_environment_t env);
117+
RAC_API bool rac_env_should_send_telemetry(rac_environment_t env);
118118

119119
/**
120120
* @brief Check if environment should sync with backend
121121
* @param env The environment
122122
* @return true for staging/production, false for development
123123
*/
124-
bool rac_env_should_sync_with_backend(rac_environment_t env);
124+
RAC_API bool rac_env_should_sync_with_backend(rac_environment_t env);
125125

126126
/**
127127
* @brief Get human-readable environment description
128128
* @param env The environment
129129
* @return String like "Development Environment"
130130
*/
131-
const char* rac_env_description(rac_environment_t env);
131+
RAC_API const char* rac_env_description(rac_environment_t env);
132132

133133
// =============================================================================
134134
// Validation Functions
@@ -155,29 +155,29 @@ typedef enum {
155155
* @param env The target environment
156156
* @return RAC_VALIDATION_OK if valid, error code otherwise
157157
*/
158-
rac_validation_result_t rac_validate_api_key(const char* api_key, rac_environment_t env);
158+
RAC_API rac_validation_result_t rac_validate_api_key(const char* api_key, rac_environment_t env);
159159

160160
/**
161161
* @brief Validate base URL for the given environment
162162
* @param url The URL to validate (can be NULL)
163163
* @param env The target environment
164164
* @return RAC_VALIDATION_OK if valid, error code otherwise
165165
*/
166-
rac_validation_result_t rac_validate_base_url(const char* url, rac_environment_t env);
166+
RAC_API rac_validation_result_t rac_validate_base_url(const char* url, rac_environment_t env);
167167

168168
/**
169169
* @brief Validate complete SDK configuration
170170
* @param config The configuration to validate
171171
* @return RAC_VALIDATION_OK if valid, first error code otherwise
172172
*/
173-
rac_validation_result_t rac_validate_config(const rac_sdk_config_t* config);
173+
RAC_API rac_validation_result_t rac_validate_config(const rac_sdk_config_t* config);
174174

175175
/**
176176
* @brief Get error message for validation result
177177
* @param result The validation result code
178178
* @return Human-readable error message
179179
*/
180-
const char* rac_validation_error_message(rac_validation_result_t result);
180+
RAC_API const char* rac_validation_error_message(rac_validation_result_t result);
181181

182182
// =============================================================================
183183
// Global SDK State

sdk/runanywhere-commons/scripts/build-ios.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,12 @@ create_backend_xcframework() {
520520
local LLAMA_BUILD="${PLATFORM_DIR}/src/backends/llamacpp/_deps/llamacpp-build"
521521
[[ ! -d "$LLAMA_BUILD" ]] && LLAMA_BUILD="${PLATFORM_DIR}/_deps/llamacpp-build"
522522

523-
for lib in llama common ggml ggml-base ggml-cpu ggml-metal ggml-blas; do
523+
for lib in llama common cpp-httplib ggml ggml-base ggml-cpu ggml-metal ggml-blas; do
524524
local lib_path=""
525525
for possible in \
526526
"${LLAMA_BUILD}/src/lib${lib}.a" \
527527
"${LLAMA_BUILD}/common/lib${lib}.a" \
528+
"${LLAMA_BUILD}/vendor/cpp-httplib/lib${lib}.a" \
528529
"${LLAMA_BUILD}/ggml/src/lib${lib}.a" \
529530
"${LLAMA_BUILD}/ggml/src/ggml-metal/lib${lib}.a" \
530531
"${LLAMA_BUILD}/ggml/src/ggml-blas/lib${lib}.a" \

0 commit comments

Comments
 (0)