|
1 | 1 | // CRACommons shim file |
2 | 2 | // This file exists to ensure Xcode's Swift Package Manager integration |
3 | 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 | +} |
0 commit comments