@runanywhere/core 0.17.8 → 0.18.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/README.md +218 -2
- package/RunAnywhereCore.podspec +1 -0
- package/android/CMakeLists.txt +24 -2
- package/android/build.gradle +61 -9
- package/android/src/main/cpp/cpp-adapter.cpp +51 -3
- package/android/src/main/include/rac/backends/rac_vlm_llamacpp.h +216 -0
- package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +3 -1
- package/android/src/main/include/rac/core/rac_core.h +11 -0
- package/android/src/main/include/rac/core/rac_types.h +8 -6
- package/android/src/main/include/rac/features/diffusion/rac_diffusion.h +22 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_component.h +263 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_model_registry.h +358 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_service.h +187 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_tokenizer.h +167 -0
- package/android/src/main/include/rac/features/diffusion/rac_diffusion_types.h +454 -0
- package/android/src/main/include/rac/features/llm/rac_tool_calling.h +373 -0
- package/android/src/main/include/rac/features/platform/rac_diffusion_platform.h +305 -0
- package/android/src/main/include/rac/features/vad/rac_vad_energy.h +1 -1
- package/android/src/main/include/rac/features/vlm/rac_vlm.h +16 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_component.h +168 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_service.h +206 -0
- package/android/src/main/include/rac/features/vlm/rac_vlm_types.h +417 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +15 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +3 -0
- package/android/src/main/include/rac/utils/rac_image_utils.h +215 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +201 -1
- package/android/src/main/jniLibs/arm64-v8a/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librac_commons.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librunanywhere_jni.so +0 -0
- package/android/src/main/jniLibs/x86_64/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/x86_64/libomp.so +0 -0
- package/android/src/main/jniLibs/x86_64/librac_commons.so +0 -0
- package/android/src/main/jniLibs/x86_64/librunanywhere_jni.so +0 -0
- package/cpp/HybridRunAnywhereCore.cpp +263 -163
- package/cpp/HybridRunAnywhereCore.hpp +11 -0
- package/cpp/bridges/InitBridge.cpp +234 -3
- package/cpp/bridges/PlatformDownloadBridge.h +44 -0
- package/cpp/bridges/ToolCallingBridge.cpp +188 -0
- package/cpp/bridges/ToolCallingBridge.hpp +98 -0
- package/cpp/third_party/nlohmann/json.hpp +24765 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +18 -4
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion.h +22 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_component.h +263 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_model_registry.h +358 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_platform.h +305 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_service.h +187 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_tokenizer.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_diffusion_types.h +454 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +3 -17
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_image_utils.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +3 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +4 -20
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +15 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +3 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tool_calling.h +373 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +8 -6
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +1 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm.h +16 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_component.h +168 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_llamacpp.h +216 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_service.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vlm_types.h +417 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/RACommons +0 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/RACommons.h +18 -4
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion.h +22 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_component.h +263 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_model_registry.h +358 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_platform.h +305 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_service.h +187 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_tokenizer.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_diffusion_types.h +454 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +3 -17
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_image_utils.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +3 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +4 -20
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +15 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +3 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tool_calling.h +373 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +8 -6
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +1 -1
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm.h +16 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_component.h +168 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_llamacpp.h +216 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_service.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vlm_types.h +417 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
- package/ios/PlatformAdapterBridge.h +24 -1
- package/ios/PlatformAdapterBridge.m +243 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +4 -0
- package/package.json +8 -4
- package/src/Foundation/Security/SecureStorageService.ts +12 -6
- package/src/Public/Extensions/RunAnywhere+Models.ts +5 -3
- package/src/Public/Extensions/RunAnywhere+STT.ts +7 -2
- package/src/Public/Extensions/RunAnywhere+ToolCalling.ts +472 -0
- package/src/Public/Extensions/index.ts +16 -0
- package/src/Public/RunAnywhere.ts +18 -0
- package/src/index.ts +0 -1
- package/src/services/Network/index.ts +0 -1
- package/src/services/index.ts +0 -1
- package/src/specs/RunAnywhereCore.nitro.ts +72 -0
- package/src/types/ToolCallingTypes.ts +198 -0
- package/src/types/index.ts +13 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rac_vlm.h
|
|
3
|
+
* @brief RunAnywhere Commons - VLM Public API
|
|
4
|
+
*
|
|
5
|
+
* Convenience header that includes all VLM-related headers.
|
|
6
|
+
* Use this for complete VLM API access.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef RAC_VLM_H
|
|
10
|
+
#define RAC_VLM_H
|
|
11
|
+
|
|
12
|
+
#include "rac/features/vlm/rac_vlm_component.h"
|
|
13
|
+
#include "rac/features/vlm/rac_vlm_service.h"
|
|
14
|
+
#include "rac/features/vlm/rac_vlm_types.h"
|
|
15
|
+
|
|
16
|
+
#endif /* RAC_VLM_H */
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rac_vlm_component.h
|
|
3
|
+
* @brief RunAnywhere Commons - VLM Capability Component
|
|
4
|
+
*
|
|
5
|
+
* Actor-based VLM capability that owns model lifecycle and generation.
|
|
6
|
+
* Uses lifecycle manager for unified lifecycle + analytics handling.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef RAC_VLM_COMPONENT_H
|
|
10
|
+
#define RAC_VLM_COMPONENT_H
|
|
11
|
+
|
|
12
|
+
#include "rac/core/capabilities/rac_lifecycle.h"
|
|
13
|
+
#include "rac/core/rac_error.h"
|
|
14
|
+
#include "rac/features/vlm/rac_vlm_types.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// VLM COMPONENT API
|
|
22
|
+
// =============================================================================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @brief Create a VLM capability component
|
|
26
|
+
*
|
|
27
|
+
* @param out_handle Output: Handle to the component
|
|
28
|
+
* @return RAC_SUCCESS or error code
|
|
29
|
+
*/
|
|
30
|
+
RAC_API rac_result_t rac_vlm_component_create(rac_handle_t* out_handle);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @brief Configure the VLM component
|
|
34
|
+
*
|
|
35
|
+
* @param handle Component handle
|
|
36
|
+
* @param config Configuration
|
|
37
|
+
* @return RAC_SUCCESS or error code
|
|
38
|
+
*/
|
|
39
|
+
RAC_API rac_result_t rac_vlm_component_configure(rac_handle_t handle,
|
|
40
|
+
const rac_vlm_config_t* config);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @brief Check if model is loaded
|
|
44
|
+
*
|
|
45
|
+
* @param handle Component handle
|
|
46
|
+
* @return RAC_TRUE if loaded, RAC_FALSE otherwise
|
|
47
|
+
*/
|
|
48
|
+
RAC_API rac_bool_t rac_vlm_component_is_loaded(rac_handle_t handle);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @brief Get current model ID
|
|
52
|
+
*
|
|
53
|
+
* @param handle Component handle
|
|
54
|
+
* @return Current model ID (NULL if not loaded)
|
|
55
|
+
*/
|
|
56
|
+
RAC_API const char* rac_vlm_component_get_model_id(rac_handle_t handle);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @brief Load a VLM model
|
|
60
|
+
*
|
|
61
|
+
* @param handle Component handle
|
|
62
|
+
* @param model_path File path to the main model (LLM weights) - REQUIRED
|
|
63
|
+
* @param mmproj_path File path to the vision projector (required for llama.cpp, NULL for MLX)
|
|
64
|
+
* @param model_id Model identifier for telemetry (optional: if NULL, defaults to model_path)
|
|
65
|
+
* @param model_name Human-readable model name (optional: if NULL, defaults to model_id)
|
|
66
|
+
* @return RAC_SUCCESS or error code
|
|
67
|
+
*/
|
|
68
|
+
RAC_API rac_result_t rac_vlm_component_load_model(rac_handle_t handle, const char* model_path,
|
|
69
|
+
const char* mmproj_path, const char* model_id,
|
|
70
|
+
const char* model_name);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @brief Unload the current model
|
|
74
|
+
*
|
|
75
|
+
* @param handle Component handle
|
|
76
|
+
* @return RAC_SUCCESS or error code
|
|
77
|
+
*/
|
|
78
|
+
RAC_API rac_result_t rac_vlm_component_unload(rac_handle_t handle);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @brief Cleanup and reset the component
|
|
82
|
+
*
|
|
83
|
+
* @param handle Component handle
|
|
84
|
+
* @return RAC_SUCCESS or error code
|
|
85
|
+
*/
|
|
86
|
+
RAC_API rac_result_t rac_vlm_component_cleanup(rac_handle_t handle);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @brief Cancel ongoing generation
|
|
90
|
+
*
|
|
91
|
+
* Best-effort cancellation.
|
|
92
|
+
*
|
|
93
|
+
* @param handle Component handle
|
|
94
|
+
* @return RAC_SUCCESS or error code
|
|
95
|
+
*/
|
|
96
|
+
RAC_API rac_result_t rac_vlm_component_cancel(rac_handle_t handle);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @brief Process an image with text prompt (non-streaming)
|
|
100
|
+
*
|
|
101
|
+
* @param handle Component handle
|
|
102
|
+
* @param image Image input
|
|
103
|
+
* @param prompt Text prompt
|
|
104
|
+
* @param options Generation options (can be NULL for defaults)
|
|
105
|
+
* @param out_result Output: Generation result
|
|
106
|
+
* @return RAC_SUCCESS or error code
|
|
107
|
+
*/
|
|
108
|
+
RAC_API rac_result_t rac_vlm_component_process(rac_handle_t handle, const rac_vlm_image_t* image,
|
|
109
|
+
const char* prompt, const rac_vlm_options_t* options,
|
|
110
|
+
rac_vlm_result_t* out_result);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @brief Check if streaming is supported
|
|
114
|
+
*
|
|
115
|
+
* @param handle Component handle
|
|
116
|
+
* @return RAC_TRUE if streaming supported, RAC_FALSE otherwise
|
|
117
|
+
*/
|
|
118
|
+
RAC_API rac_bool_t rac_vlm_component_supports_streaming(rac_handle_t handle);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @brief Process an image with streaming
|
|
122
|
+
*
|
|
123
|
+
* @param handle Component handle
|
|
124
|
+
* @param image Image input
|
|
125
|
+
* @param prompt Text prompt
|
|
126
|
+
* @param options Generation options (can be NULL for defaults)
|
|
127
|
+
* @param token_callback Called for each generated token
|
|
128
|
+
* @param complete_callback Called when generation completes
|
|
129
|
+
* @param error_callback Called on error
|
|
130
|
+
* @param user_data User context passed to callbacks
|
|
131
|
+
* @return RAC_SUCCESS or error code
|
|
132
|
+
*/
|
|
133
|
+
RAC_API rac_result_t rac_vlm_component_process_stream(
|
|
134
|
+
rac_handle_t handle, const rac_vlm_image_t* image, const char* prompt,
|
|
135
|
+
const rac_vlm_options_t* options, rac_vlm_component_token_callback_fn token_callback,
|
|
136
|
+
rac_vlm_component_complete_callback_fn complete_callback,
|
|
137
|
+
rac_vlm_component_error_callback_fn error_callback, void* user_data);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @brief Get lifecycle state
|
|
141
|
+
*
|
|
142
|
+
* @param handle Component handle
|
|
143
|
+
* @return Current lifecycle state
|
|
144
|
+
*/
|
|
145
|
+
RAC_API rac_lifecycle_state_t rac_vlm_component_get_state(rac_handle_t handle);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @brief Get lifecycle metrics
|
|
149
|
+
*
|
|
150
|
+
* @param handle Component handle
|
|
151
|
+
* @param out_metrics Output: Lifecycle metrics
|
|
152
|
+
* @return RAC_SUCCESS or error code
|
|
153
|
+
*/
|
|
154
|
+
RAC_API rac_result_t rac_vlm_component_get_metrics(rac_handle_t handle,
|
|
155
|
+
rac_lifecycle_metrics_t* out_metrics);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @brief Destroy the VLM component
|
|
159
|
+
*
|
|
160
|
+
* @param handle Component handle
|
|
161
|
+
*/
|
|
162
|
+
RAC_API void rac_vlm_component_destroy(rac_handle_t handle);
|
|
163
|
+
|
|
164
|
+
#ifdef __cplusplus
|
|
165
|
+
}
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
#endif /* RAC_VLM_COMPONENT_H */
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rac_vlm_service.h
|
|
3
|
+
* @brief RunAnywhere Commons - VLM Service Interface
|
|
4
|
+
*
|
|
5
|
+
* Defines the generic VLM service API and vtable for multi-backend dispatch.
|
|
6
|
+
* Backends (LlamaCpp VLM, MLX VLM) implement the vtable and register
|
|
7
|
+
* with the service registry.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#ifndef RAC_VLM_SERVICE_H
|
|
11
|
+
#define RAC_VLM_SERVICE_H
|
|
12
|
+
|
|
13
|
+
#include "rac/core/rac_error.h"
|
|
14
|
+
#include "rac/features/vlm/rac_vlm_types.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// SERVICE VTABLE - Backend implementations provide this
|
|
22
|
+
// =============================================================================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* VLM Service operations vtable.
|
|
26
|
+
* Each backend implements these functions and provides a static vtable.
|
|
27
|
+
*/
|
|
28
|
+
typedef struct rac_vlm_service_ops {
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the service with model path(s).
|
|
31
|
+
* @param impl Backend implementation handle
|
|
32
|
+
* @param model_path Path to the main model file (LLM weights)
|
|
33
|
+
* @param mmproj_path Path to vision projector (required for llama.cpp, NULL for MLX)
|
|
34
|
+
* @return RAC_SUCCESS or error code
|
|
35
|
+
*/
|
|
36
|
+
rac_result_t (*initialize)(void* impl, const char* model_path, const char* mmproj_path);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Process an image with a text prompt (blocking).
|
|
40
|
+
* @param impl Backend implementation handle
|
|
41
|
+
* @param image Image input
|
|
42
|
+
* @param prompt Text prompt
|
|
43
|
+
* @param options Generation options (can be NULL for defaults)
|
|
44
|
+
* @param out_result Output result (caller must free with rac_vlm_result_free)
|
|
45
|
+
* @return RAC_SUCCESS or error code
|
|
46
|
+
*/
|
|
47
|
+
rac_result_t (*process)(void* impl, const rac_vlm_image_t* image, const char* prompt,
|
|
48
|
+
const rac_vlm_options_t* options, rac_vlm_result_t* out_result);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Process an image with streaming callback.
|
|
52
|
+
* @param impl Backend implementation handle
|
|
53
|
+
* @param image Image input
|
|
54
|
+
* @param prompt Text prompt
|
|
55
|
+
* @param options Generation options (can be NULL for defaults)
|
|
56
|
+
* @param callback Token callback
|
|
57
|
+
* @param user_data User context for callback
|
|
58
|
+
* @return RAC_SUCCESS or error code
|
|
59
|
+
*/
|
|
60
|
+
rac_result_t (*process_stream)(void* impl, const rac_vlm_image_t* image, const char* prompt,
|
|
61
|
+
const rac_vlm_options_t* options,
|
|
62
|
+
rac_vlm_stream_callback_fn callback, void* user_data);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get service information.
|
|
66
|
+
* @param impl Backend implementation handle
|
|
67
|
+
* @param out_info Output info structure
|
|
68
|
+
* @return RAC_SUCCESS or error code
|
|
69
|
+
*/
|
|
70
|
+
rac_result_t (*get_info)(void* impl, rac_vlm_info_t* out_info);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Cancel ongoing generation.
|
|
74
|
+
* @param impl Backend implementation handle
|
|
75
|
+
* @return RAC_SUCCESS or error code
|
|
76
|
+
*/
|
|
77
|
+
rac_result_t (*cancel)(void* impl);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Cleanup/unload model (keeps service alive).
|
|
81
|
+
* @param impl Backend implementation handle
|
|
82
|
+
* @return RAC_SUCCESS or error code
|
|
83
|
+
*/
|
|
84
|
+
rac_result_t (*cleanup)(void* impl);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Destroy the service.
|
|
88
|
+
* @param impl Backend implementation handle
|
|
89
|
+
*/
|
|
90
|
+
void (*destroy)(void* impl);
|
|
91
|
+
} rac_vlm_service_ops_t;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* VLM Service instance.
|
|
95
|
+
* Contains vtable pointer and backend-specific implementation.
|
|
96
|
+
*/
|
|
97
|
+
typedef struct rac_vlm_service {
|
|
98
|
+
/** Vtable with backend operations */
|
|
99
|
+
const rac_vlm_service_ops_t* ops;
|
|
100
|
+
|
|
101
|
+
/** Backend-specific implementation handle */
|
|
102
|
+
void* impl;
|
|
103
|
+
|
|
104
|
+
/** Model ID for reference */
|
|
105
|
+
const char* model_id;
|
|
106
|
+
} rac_vlm_service_t;
|
|
107
|
+
|
|
108
|
+
// =============================================================================
|
|
109
|
+
// PUBLIC API - Generic service functions
|
|
110
|
+
// =============================================================================
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @brief Create a VLM service
|
|
114
|
+
*
|
|
115
|
+
* Routes through service registry to find appropriate backend.
|
|
116
|
+
*
|
|
117
|
+
* @param model_id Model identifier (registry ID or path to model file)
|
|
118
|
+
* @param out_handle Output: Handle to the created service
|
|
119
|
+
* @return RAC_SUCCESS or error code
|
|
120
|
+
*/
|
|
121
|
+
RAC_API rac_result_t rac_vlm_create(const char* model_id, rac_handle_t* out_handle);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @brief Initialize a VLM service with model paths
|
|
125
|
+
*
|
|
126
|
+
* @param handle Service handle
|
|
127
|
+
* @param model_path Path to the main model file
|
|
128
|
+
* @param mmproj_path Path to vision projector (can be NULL for some backends)
|
|
129
|
+
* @return RAC_SUCCESS or error code
|
|
130
|
+
*/
|
|
131
|
+
RAC_API rac_result_t rac_vlm_initialize(rac_handle_t handle, const char* model_path,
|
|
132
|
+
const char* mmproj_path);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @brief Process an image with a text prompt
|
|
136
|
+
*
|
|
137
|
+
* @param handle Service handle
|
|
138
|
+
* @param image Image input
|
|
139
|
+
* @param prompt Text prompt describing what to analyze
|
|
140
|
+
* @param options Generation options (can be NULL for defaults)
|
|
141
|
+
* @param out_result Output: Generation result (caller must free with rac_vlm_result_free)
|
|
142
|
+
* @return RAC_SUCCESS or error code
|
|
143
|
+
*/
|
|
144
|
+
RAC_API rac_result_t rac_vlm_process(rac_handle_t handle, const rac_vlm_image_t* image,
|
|
145
|
+
const char* prompt, const rac_vlm_options_t* options,
|
|
146
|
+
rac_vlm_result_t* out_result);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @brief Process an image with streaming response
|
|
150
|
+
*
|
|
151
|
+
* @param handle Service handle
|
|
152
|
+
* @param image Image input
|
|
153
|
+
* @param prompt Text prompt
|
|
154
|
+
* @param options Generation options (can be NULL for defaults)
|
|
155
|
+
* @param callback Callback for each generated token
|
|
156
|
+
* @param user_data User context passed to callback
|
|
157
|
+
* @return RAC_SUCCESS or error code
|
|
158
|
+
*/
|
|
159
|
+
RAC_API rac_result_t rac_vlm_process_stream(rac_handle_t handle, const rac_vlm_image_t* image,
|
|
160
|
+
const char* prompt, const rac_vlm_options_t* options,
|
|
161
|
+
rac_vlm_stream_callback_fn callback, void* user_data);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @brief Get service information
|
|
165
|
+
*
|
|
166
|
+
* @param handle Service handle
|
|
167
|
+
* @param out_info Output: Service information
|
|
168
|
+
* @return RAC_SUCCESS or error code
|
|
169
|
+
*/
|
|
170
|
+
RAC_API rac_result_t rac_vlm_get_info(rac_handle_t handle, rac_vlm_info_t* out_info);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @brief Cancel ongoing generation
|
|
174
|
+
*
|
|
175
|
+
* @param handle Service handle
|
|
176
|
+
* @return RAC_SUCCESS or error code
|
|
177
|
+
*/
|
|
178
|
+
RAC_API rac_result_t rac_vlm_cancel(rac_handle_t handle);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @brief Cleanup and release model resources
|
|
182
|
+
*
|
|
183
|
+
* @param handle Service handle
|
|
184
|
+
* @return RAC_SUCCESS or error code
|
|
185
|
+
*/
|
|
186
|
+
RAC_API rac_result_t rac_vlm_cleanup(rac_handle_t handle);
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @brief Destroy a VLM service instance
|
|
190
|
+
*
|
|
191
|
+
* @param handle Service handle to destroy
|
|
192
|
+
*/
|
|
193
|
+
RAC_API void rac_vlm_destroy(rac_handle_t handle);
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @brief Free a VLM result
|
|
197
|
+
*
|
|
198
|
+
* @param result Result to free
|
|
199
|
+
*/
|
|
200
|
+
RAC_API void rac_vlm_result_free(rac_vlm_result_t* result);
|
|
201
|
+
|
|
202
|
+
#ifdef __cplusplus
|
|
203
|
+
}
|
|
204
|
+
#endif
|
|
205
|
+
|
|
206
|
+
#endif /* RAC_VLM_SERVICE_H */
|