|
1 | | -// CRACommons shim file |
2 | | -// This file exists to ensure Xcode's Swift Package Manager integration |
3 | | -// can build this module. The actual implementation is in the binary target. |
4 | | -// |
5 | | -// Stub implementations below satisfy the linker for functions that are |
6 | | -// declared in headers but whose backends (RAG, LoRA) are not yet compiled |
7 | | -// into the release binary targets. At runtime these return |
8 | | -// RAC_ERROR_NOT_IMPLEMENTED so callers get a clear error instead of a crash. |
9 | | -// |
10 | | -// When the real backend binaries include these symbols the linker will |
11 | | -// prefer the strong definitions and these weak stubs are ignored. |
12 | | - |
13 | | -#include "include/rac_types.h" |
14 | | -#include "include/rac_error.h" |
15 | | -#include "include/rac_llm_component.h" |
16 | | -#include "include/rac_rag_pipeline.h" |
17 | | -#include <stddef.h> |
18 | | - |
19 | | -// ============================================================================= |
20 | | -// LoRA stubs (declared in rac_llm_component.h, not yet in RACommons binary) |
21 | | -// TODO: Remove these stubs once LoRA support is implemented in the |
22 | | -// runanywhere-commons C++ library and compiled into RACommons.xcframework. |
23 | | -// ============================================================================= |
24 | | - |
25 | | -__attribute__((weak)) |
26 | | -rac_result_t rac_llm_component_load_lora(rac_handle_t handle, |
27 | | - const char* adapter_path, |
28 | | - float scale) { |
29 | | - (void)handle; (void)adapter_path; (void)scale; |
30 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation in RACommons C++ |
31 | | -} |
32 | | - |
33 | | -__attribute__((weak)) |
34 | | -rac_result_t rac_llm_component_remove_lora(rac_handle_t handle, |
35 | | - const char* adapter_path) { |
36 | | - (void)handle; (void)adapter_path; |
37 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation in RACommons C++ |
38 | | -} |
39 | | - |
40 | | -__attribute__((weak)) |
41 | | -rac_result_t rac_llm_component_clear_lora(rac_handle_t handle) { |
42 | | - (void)handle; |
43 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation in RACommons C++ |
44 | | -} |
45 | | - |
46 | | -__attribute__((weak)) |
47 | | -rac_result_t rac_llm_component_get_lora_info(rac_handle_t handle, |
48 | | - char** out_json) { |
49 | | - (void)handle; (void)out_json; |
50 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation in RACommons C++ |
51 | | -} |
52 | | - |
53 | | -// ============================================================================= |
54 | | -// RAG stubs (declared in rac_rag_pipeline.h, implemented in RABackendRAG |
55 | | -// which is not included in remote-mode releases yet) |
56 | | -// TODO: Remove these stubs once RABackendRAG.xcframework is published to |
57 | | -// GitHub releases and ragRemoteBinaryAvailable is set to true. |
58 | | -// ============================================================================= |
59 | | - |
60 | | -__attribute__((weak)) |
61 | | -rac_result_t rac_rag_pipeline_create(const rac_rag_config_t* config, |
62 | | - rac_rag_pipeline_t** out_pipeline) { |
63 | | - (void)config; (void)out_pipeline; |
64 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
65 | | -} |
66 | | - |
67 | | -__attribute__((weak)) |
68 | | -rac_result_t rac_rag_add_document(rac_rag_pipeline_t* pipeline, |
69 | | - const char* document_text, |
70 | | - const char* metadata_json) { |
71 | | - (void)pipeline; (void)document_text; (void)metadata_json; |
72 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
73 | | -} |
74 | | - |
75 | | -__attribute__((weak)) |
76 | | -rac_result_t rac_rag_add_documents_batch(rac_rag_pipeline_t* pipeline, |
77 | | - const char** documents, |
78 | | - const char** metadata_array, |
79 | | - size_t count) { |
80 | | - (void)pipeline; (void)documents; (void)metadata_array; (void)count; |
81 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
82 | | -} |
83 | | - |
84 | | -__attribute__((weak)) |
85 | | -rac_result_t rac_rag_query(rac_rag_pipeline_t* pipeline, |
86 | | - const rac_rag_query_t* query, |
87 | | - rac_rag_result_t* out_result) { |
88 | | - (void)pipeline; (void)query; (void)out_result; |
89 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
90 | | -} |
91 | | - |
92 | | -__attribute__((weak)) |
93 | | -rac_result_t rac_rag_clear_documents(rac_rag_pipeline_t* pipeline) { |
94 | | - (void)pipeline; |
95 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
96 | | -} |
97 | | - |
98 | | -__attribute__((weak)) |
99 | | -size_t rac_rag_get_document_count(rac_rag_pipeline_t* pipeline) { |
100 | | - (void)pipeline; |
101 | | - return 0; // TODO: Remove stub when RABackendRAG release binary is available |
102 | | -} |
103 | | - |
104 | | -__attribute__((weak)) |
105 | | -rac_result_t rac_rag_get_statistics(rac_rag_pipeline_t* pipeline, |
106 | | - char** out_stats_json) { |
107 | | - (void)pipeline; (void)out_stats_json; |
108 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Remove stub when RABackendRAG release binary is available |
109 | | -} |
110 | | - |
111 | | -__attribute__((weak)) |
112 | | -void rac_rag_result_free(rac_rag_result_t* result) { |
113 | | - (void)result; |
114 | | - // TODO: Remove stub when RABackendRAG release binary is available |
115 | | -} |
116 | | - |
117 | | -__attribute__((weak)) |
118 | | -void rac_rag_pipeline_destroy(rac_rag_pipeline_t* pipeline) { |
119 | | - (void)pipeline; |
120 | | - // TODO: Remove stub when RABackendRAG release binary is available |
121 | | -} |
122 | | - |
123 | | -// ============================================================================= |
124 | | -// Voice Agent stubs (declared in rac_voice_agent.h, not yet in RACommons binary) |
125 | | -// TODO: Remove these stubs once voice agent is implemented in RACommons C++. |
126 | | -// ============================================================================= |
127 | | - |
128 | | -#include "include/rac_voice_agent.h" |
129 | | - |
130 | | -__attribute__((weak)) |
131 | | -rac_result_t rac_voice_agent_process_voice_turn(rac_voice_agent_handle_t handle, |
132 | | - const void* audio_data, size_t audio_size, |
133 | | - rac_voice_agent_result_t* out_result) { |
134 | | - (void)handle; (void)audio_data; (void)audio_size; (void)out_result; |
135 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation |
136 | | -} |
137 | | - |
138 | | -__attribute__((weak)) |
139 | | -rac_result_t rac_voice_agent_transcribe(rac_voice_agent_handle_t handle, |
140 | | - const void* audio_data, size_t audio_size, |
141 | | - char** out_transcription) { |
142 | | - (void)handle; (void)audio_data; (void)audio_size; (void)out_transcription; |
143 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation |
144 | | -} |
145 | | - |
146 | | -__attribute__((weak)) |
147 | | -rac_result_t rac_voice_agent_synthesize_speech(rac_voice_agent_handle_t handle, |
148 | | - const char* text, void** out_audio, |
149 | | - size_t* out_audio_size) { |
150 | | - (void)handle; (void)text; (void)out_audio; (void)out_audio_size; |
151 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation |
152 | | -} |
153 | | - |
154 | | -__attribute__((weak)) |
155 | | -void rac_voice_agent_result_free(rac_voice_agent_result_t* result) { |
156 | | - (void)result; |
157 | | - // TODO: Replace with real implementation |
158 | | -} |
159 | | - |
160 | | -// ============================================================================= |
161 | | -// WhisperKit CoreML STT stubs |
162 | | -// TODO: Remove once implemented in RACommons C++. |
163 | | -// ============================================================================= |
164 | | - |
165 | | -#include "include/rac_stt_whisperkit_coreml.h" |
166 | | - |
167 | | -__attribute__((weak)) |
168 | | -rac_result_t rac_whisperkit_coreml_stt_set_callbacks( |
169 | | - const rac_whisperkit_coreml_stt_callbacks_t* callbacks) { |
170 | | - (void)callbacks; |
171 | | - return RAC_ERROR_NOT_IMPLEMENTED; // TODO: Replace with real implementation |
172 | | -} |
| 1 | +// CRACommons shim — SPM requires at least one source file for C targets. |
| 2 | +// All real implementations live in the xcframework binary targets: |
| 3 | +// - RACommons.xcframework (LoRA, Voice Agent, core) |
| 4 | +// - RABackendRAG.xcframework (RAG pipeline) |
| 5 | +// - RABackendONNX.xcframework (STT/TTS/VAD) |
0 commit comments