| 290 | } |
| 291 | |
| 292 | JNIEXPORT jstring JNICALL |
| 293 | Java_com_cactus_CactusJNI_nativeRagQuery(JNIEnv* env, jobject, jlong handle, |
| 294 | jstring query, jint topK) { |
| 295 | if (handle == 0) { throwCactusException(env, "Model not initialized"); return nullptr; } |
| 296 | |
| 297 | const char* queryStr = jstring_to_cstr(env, query); |
| 298 | |
| 299 | std::vector<char> buffer(DEFAULT_BUFFER_SIZE); |
| 300 | |
| 301 | int result = cactus_rag_query( |
| 302 | reinterpret_cast<cactus_model_t>(handle), |
| 303 | queryStr, |
| 304 | buffer.data(), |
| 305 | buffer.size(), |
| 306 | static_cast<size_t>(topK) |
| 307 | ); |
| 308 | |
| 309 | release_jstring(env, query, queryStr); |
| 310 | |
| 311 | if (result < 0) { throwOnError(env); return nullptr; } |
| 312 | return env->NewStringUTF(buffer.data()); |
| 313 | } |
| 314 | |
| 315 | JNIEXPORT jstring JNICALL |
| 316 | Java_com_cactus_CactusJNI_nativeGetLastError(JNIEnv* env, jobject) { |
nothing calls this directly
no test coverage detected