- Remove ALPR_OD Tracker and voting system.
- Disable debugview
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
|
||||
// DebugView: filter on "[ANSLLM]" — gated by ANSCORE_DEBUGVIEW in ANSLicense.h.
|
||||
|
||||
// Handle registry with refcount — prevents use-after-free when
|
||||
// ReleaseANSLLMHandle is called while an operation is still running.
|
||||
// destructionStarted: set by the first Unregister caller; blocks new Acquires
|
||||
@@ -29,14 +31,30 @@ static std::condition_variable& LLMHandleRegistryCV() {
|
||||
static void RegisterLLMHandle(ANSCENTER::ANSLLM* h) {
|
||||
std::lock_guard<std::mutex> lk(LLMHandleRegistryMutex());
|
||||
LLMHandleRegistry()[h] = { 1, false };
|
||||
ANS_DBG("ANSLLM","Register: handle=%p (uint=%llu) registrySize=%zu",
|
||||
(void*)h, (unsigned long long)(uintptr_t)h, LLMHandleRegistry().size());
|
||||
}
|
||||
|
||||
static ANSCENTER::ANSLLM* AcquireLLMHandle(ANSCENTER::ANSLLM* h) {
|
||||
std::lock_guard<std::mutex> lk(LLMHandleRegistryMutex());
|
||||
auto it = LLMHandleRegistry().find(h);
|
||||
if (it == LLMHandleRegistry().end()) return nullptr;
|
||||
if (it->second.destructionStarted) return nullptr;
|
||||
if (it == LLMHandleRegistry().end()) {
|
||||
ANS_DBG("ANSLLM","Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
|
||||
(void*)h, (unsigned long long)(uintptr_t)h, LLMHandleRegistry().size());
|
||||
size_t i = 0;
|
||||
for (auto& kv : LLMHandleRegistry()) {
|
||||
ANS_DBG("ANSLLM"," registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d",
|
||||
i++, (void*)kv.first, (unsigned long long)(uintptr_t)kv.first,
|
||||
kv.second.refcount, kv.second.destructionStarted ? 1 : 0);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (it->second.destructionStarted) {
|
||||
ANS_DBG("ANSLLM","Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
|
||||
return nullptr;
|
||||
}
|
||||
it->second.refcount++;
|
||||
ANS_DBG("ANSLLM","Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -54,10 +72,15 @@ static bool ReleaseLLMHandleRef(ANSCENTER::ANSLLM* h) {
|
||||
static bool UnregisterLLMHandle(ANSCENTER::ANSLLM* h) {
|
||||
std::unique_lock<std::mutex> lk(LLMHandleRegistryMutex());
|
||||
auto it = LLMHandleRegistry().find(h);
|
||||
if (it == LLMHandleRegistry().end()) return false;
|
||||
if (it == LLMHandleRegistry().end()) {
|
||||
ANS_DBG("ANSLLM","Unregister: handle=%p NOT in registry (already gone)", (void*)h);
|
||||
return false;
|
||||
}
|
||||
if (it->second.destructionStarted) {
|
||||
ANS_DBG("ANSLLM","Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
|
||||
return false; // Another thread already owns the delete.
|
||||
}
|
||||
ANS_DBG("ANSLLM","Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
|
||||
it->second.destructionStarted = true;
|
||||
it->second.refcount--;
|
||||
bool ok = LLMHandleRegistryCV().wait_for(lk, std::chrono::seconds(30), [&]() {
|
||||
@@ -65,6 +88,7 @@ static bool UnregisterLLMHandle(ANSCENTER::ANSLLM* h) {
|
||||
return it2 == LLMHandleRegistry().end() || it2->second.refcount <= 0;
|
||||
});
|
||||
if (!ok) {
|
||||
ANS_DBG("ANSLLM","WARNING: Unregister timed out waiting for in-flight operations on handle=%p", (void*)h);
|
||||
OutputDebugStringA("WARNING: UnregisterLLMHandle timed out waiting for in-flight operations\n");
|
||||
}
|
||||
LLMHandleRegistry().erase(h);
|
||||
@@ -112,7 +136,10 @@ static int CopyToLStrHandle(LStrHandle handle, const std::string& str) noexcept
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int CreateANSLLMHandle(ANSCENTER::ANSLLM** Handle, const char* licenseKey, int localLLM) {
|
||||
if (Handle == nullptr || licenseKey == nullptr) return 0;
|
||||
ANS_DBG("ANSLLM","Create called: HandlePtr=%p, *Handle(in)=%p, localLLM=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), localLLM);
|
||||
if (Handle == nullptr) { ANS_DBG("ANSLLM","Create FAIL: Handle is null"); return 0; }
|
||||
if (licenseKey == nullptr) { ANS_DBG("ANSLLM","Create FAIL: licenseKey is null"); return 0; }
|
||||
try {
|
||||
// Pure constructor: ignore *Handle(in). LabVIEW's CLF Node marshalling
|
||||
// reuses the same temp buffer per call site, so *Handle(in) often holds
|
||||
@@ -126,37 +153,52 @@ extern "C" ANSLLM_API int CreateANSLLMHandle(ANSCENTER::ANSLLM** Handle, const
|
||||
|
||||
// std::unique_ptr ensures automatic cleanup on any failure path
|
||||
auto ptr = std::make_unique<ANSCENTER::ANSLLM>();
|
||||
ANS_DBG("ANSLLM","Create: allocated handle=%p (uint=%llu), calling Initialize...",
|
||||
(void*)ptr.get(), (unsigned long long)(uintptr_t)ptr.get());
|
||||
if (!ptr->Initialize(licenseKey, localLLM != 0)) {
|
||||
// unique_ptr automatically deletes — no leak
|
||||
ANS_DBG("ANSLLM","Create FAIL: Initialize returned false, handle=%p auto-deleted", (void*)ptr.get());
|
||||
*Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
// Transfer ownership to caller on success
|
||||
*Handle = ptr.release();
|
||||
RegisterLLMHandle(*Handle);
|
||||
ANS_DBG("ANSLLM","Create OK: handle=%p (uint=%llu)", (void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
|
||||
return 1;
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
catch (const std::exception& e) {
|
||||
ANS_DBG("ANSLLM","Create EXCEPTION (std::exception): %s", e.what());
|
||||
*Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
catch (...) {
|
||||
ANS_DBG("ANSLLM","Create EXCEPTION (unknown)");
|
||||
*Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static int ReleaseANSLLMHandle_Impl(ANSCENTER::ANSLLM** Handle) {
|
||||
try {
|
||||
if (!Handle || !*Handle) return 1;
|
||||
if (!UnregisterLLMHandle(*Handle)) {
|
||||
if (!Handle || !*Handle) {
|
||||
ANS_DBG("ANSLLM","Release: HandlePtr or *Handle is null, no-op");
|
||||
return 1;
|
||||
}
|
||||
ANSCENTER::ANSLLM* h = *Handle;
|
||||
ANS_DBG("ANSLLM","Release called: handle=%p (uint=%llu)", (void*)h, (unsigned long long)(uintptr_t)h);
|
||||
if (!UnregisterLLMHandle(h)) {
|
||||
ANS_DBG("ANSLLM","Release: Unregister returned false (already gone or being destroyed by another thread), handle=%p", (void*)h);
|
||||
*Handle = nullptr;
|
||||
return 1;
|
||||
}
|
||||
delete *Handle;
|
||||
delete h;
|
||||
*Handle = nullptr;
|
||||
ANS_DBG("ANSLLM","Release OK: handle=%p deleted, registry now has %zu entries",
|
||||
(void*)h, LLMHandleRegistry().size());
|
||||
return 1;
|
||||
}
|
||||
catch (...) {
|
||||
ANS_DBG("ANSLLM","Release EXCEPTION (unknown)");
|
||||
if (Handle) *Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
@@ -167,12 +209,15 @@ extern "C" ANSLLM_API int ReleaseANSLLMHandle(ANSCENTER::ANSLLM** Handle) {
|
||||
return ReleaseANSLLMHandle_Impl(Handle);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
ANS_DBG("ANSLLM","ReleaseANSLLMHandle: SEH exception caught");
|
||||
if (Handle) *Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int SetANSLLMProvider(ANSCENTER::ANSLLM** Handle, const char* provider) {
|
||||
ANS_DBG("ANSLLM","SetANSLLMProvider: HandlePtr=%p, *Handle=%p, provider=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), provider ? provider : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || provider == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -187,6 +232,7 @@ extern "C" ANSLLM_API int SetANSLLMProvider(ANSCENTER::ANSLLM** Handle, const c
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int GetANSLLMProvider(ANSCENTER::ANSLLM** Handle, LStrHandle provider) {
|
||||
ANS_DBG("ANSLLM","GetANSLLMProvider: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -202,6 +248,7 @@ extern "C" ANSLLM_API int GetANSLLMProvider(ANSCENTER::ANSLLM** Handle, LStrHan
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int SetApiKey(ANSCENTER::ANSLLM** Handle, const char* apiKey) {
|
||||
ANS_DBG("ANSLLM","SetApiKey: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr || apiKey == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -218,6 +265,7 @@ extern "C" ANSLLM_API int SetApiKey(ANSCENTER::ANSLLM** Handle, const char* api
|
||||
|
||||
|
||||
extern "C" ANSLLM_API int ANSLLMGetModelList(ANSCENTER::ANSLLM** Handle, LStrHandle modelList) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetModelList: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -238,6 +286,8 @@ extern "C" ANSLLM_API int ANSLLMGetModelList(ANSCENTER::ANSLLM** Handle, LStrHa
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetTranscriptMode(ANSCENTER::ANSLLM** Handle, int transcriptMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetTranscriptMode: HandlePtr=%p, *Handle=%p, transcriptMode=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), transcriptMode);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -252,6 +302,8 @@ extern "C" ANSLLM_API int ANSLLMSetTranscriptMode(ANSCENTER::ANSLLM** Handle, i
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetModel(ANSCENTER::ANSLLM** Handle, const char* modelName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetModel: HandlePtr=%p, *Handle=%p, modelName=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), modelName ? modelName : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || modelName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -267,6 +319,7 @@ extern "C" ANSLLM_API int ANSLLMSetModel(ANSCENTER::ANSLLM** Handle, const char
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddText(ANSCENTER::ANSLLM** Handle, const char* inputText) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddText: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr || inputText == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -281,6 +334,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddText(ANSCENTER::ANSLLM** Handle, const
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageUrl(ANSCENTER::ANSLLM** Handle, const char* imageURL, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageUrl: HandlePtr=%p, *Handle=%p, imageURL=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), imageURL ? imageURL : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || imageURL == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -296,6 +351,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageUrl(ANSCENTER::ANSLLM** Handle, co
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageFromPath(ANSCENTER::ANSLLM** Handle, const char* filePath, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageFromPath: HandlePtr=%p, *Handle=%p, filePath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), filePath ? filePath : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || filePath == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -311,6 +368,7 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageFromPath(ANSCENTER::ANSLLM** Handl
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageFromBase64(ANSCENTER::ANSLLM** Handle, const char* base64Image, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageFromBase64: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr || base64Image == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -326,6 +384,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageFromBase64(ANSCENTER::ANSLLM** Han
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddFileURL(ANSCENTER::ANSLLM** Handle, const char* fileURL, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddFileURL: HandlePtr=%p, *Handle=%p, fileURL=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), fileURL ? fileURL : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || fileURL == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -341,6 +401,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddFileURL(ANSCENTER::ANSLLM** Handle, con
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddFileData(ANSCENTER::ANSLLM** Handle, const char* filePath, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddFileData: HandlePtr=%p, *Handle=%p, filePath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), filePath ? filePath : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || filePath == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -356,6 +418,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddFileData(ANSCENTER::ANSLLM** Handle, co
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMCreateConversation(ANSCENTER::ANSLLM** Handle, const char* systemMessage, const char* developerMessage, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMCreateConversation: HandlePtr=%p, *Handle=%p, conversationName=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), conversationName ? conversationName : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
if (systemMessage == nullptr || developerMessage == nullptr || conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
@@ -371,6 +435,8 @@ extern "C" ANSLLM_API int ANSLLMCreateConversation(ANSCENTER::ANSLLM** Handle,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetConversation(ANSCENTER::ANSLLM** Handle, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetConversation: HandlePtr=%p, *Handle=%p, conversationName=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), conversationName ? conversationName : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -385,6 +451,7 @@ extern "C" ANSLLM_API int ANSLLMSetConversation(ANSCENTER::ANSLLM** Handle, con
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMAsk(ANSCENTER::ANSLLM** Handle, const char* prompt, LStrHandle response) {
|
||||
ANS_DBG("ANSLLM","ANSLLMAsk: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr || prompt == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -400,6 +467,7 @@ extern "C" ANSLLM_API int ANSLLMAsk(ANSCENTER::ANSLLM** Handle, const char* pro
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int ANSLLMClearInput(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMClearInput: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -414,6 +482,7 @@ extern "C" ANSLLM_API int ANSLLMClearInput(ANSCENTER::ANSLLM** Handle) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetConversationList(ANSCENTER::ANSLLM** Handle, LStrHandle conversationList) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetConversationList: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -434,6 +503,8 @@ extern "C" ANSLLM_API int ANSLLMGetConversationList(ANSCENTER::ANSLLM** Handle,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMDeleteConversation(ANSCENTER::ANSLLM** Handle, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMDeleteConversation: HandlePtr=%p, *Handle=%p, conversationName=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), conversationName ? conversationName : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -448,6 +519,8 @@ extern "C" ANSLLM_API int ANSLLMDeleteConversation(ANSCENTER::ANSLLM** Handle,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetUTF8(ANSCENTER::ANSLLM** Handle, int utf8Mode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetUTF8: HandlePtr=%p, *Handle=%p, utf8Mode=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), utf8Mode);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -462,6 +535,7 @@ extern "C" ANSLLM_API int ANSLLMSetUTF8(ANSCENTER::ANSLLM** Handle, int utf8Mod
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetUTF8(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetUTF8: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -476,6 +550,8 @@ extern "C" ANSLLM_API int ANSLLMGetUTF8(ANSCENTER::ANSLLM** Handle) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMPollAi(ANSCENTER::ANSLLM** Handle, int abort) {
|
||||
ANS_DBG("ANSLLM","ANSLLMPollAi: HandlePtr=%p, *Handle=%p, abort=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), abort);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -491,6 +567,8 @@ extern "C" ANSLLM_API int ANSLLMPollAi(ANSCENTER::ANSLLM** Handle, int abort) {
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int ANSLLMSetLocalLLM(ANSCENTER::ANSLLM** Handle, int localLLM) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetLocalLLM: HandlePtr=%p, *Handle=%p, localLLM=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), localLLM);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -505,6 +583,8 @@ extern "C" ANSLLM_API int ANSLLMSetLocalLLM(ANSCENTER::ANSLLM** Handle, int loc
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetOllamaBaseUrl(ANSCENTER::ANSLLM** Handle, const char* baseUrl) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetOllamaBaseUrl: HandlePtr=%p, *Handle=%p, baseUrl=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), baseUrl ? baseUrl : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || baseUrl == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -519,6 +599,8 @@ extern "C" ANSLLM_API int ANSLLMSetOllamaBaseUrl(ANSCENTER::ANSLLM** Handle, co
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetBaseURL(ANSCENTER::ANSLLM** Handle, const char* baseURL) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetBaseURL: HandlePtr=%p, *Handle=%p, baseURL=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), baseURL ? baseURL : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr || baseURL == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -533,6 +615,8 @@ extern "C" ANSLLM_API int ANSLLMSetBaseURL(ANSCENTER::ANSLLM** Handle, const ch
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetHeartbeatMs(ANSCENTER::ANSLLM** Handle, int heartbeatMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetHeartbeatMs: HandlePtr=%p, *Handle=%p, heartbeatMs=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), heartbeatMs);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -547,6 +631,7 @@ extern "C" ANSLLM_API int ANSLLMSetHeartbeatMs(ANSCENTER::ANSLLM** Handle, int
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetHeartbeatMs(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetHeartbeatMs: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return -1;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return -1;
|
||||
@@ -561,6 +646,8 @@ extern "C" ANSLLM_API int ANSLLMGetHeartbeatMs(ANSCENTER::ANSLLM** Handle) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetHostedConversation(ANSCENTER::ANSLLM** Handle, int hostedConversationMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetHostedConversation: HandlePtr=%p, *Handle=%p, hostedConversationMode=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), hostedConversationMode);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -575,6 +662,7 @@ extern "C" ANSLLM_API int ANSLLMSetHostedConversation(ANSCENTER::ANSLLM** Handl
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetHostedConversation(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetHostedConversation: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -589,6 +677,7 @@ extern "C" ANSLLM_API int ANSLLMGetHostedConversation(ANSCENTER::ANSLLM** Handl
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetStreamingMode(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetStreamingMode: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -603,6 +692,8 @@ extern "C" ANSLLM_API int ANSLLMGetStreamingMode(ANSCENTER::ANSLLM** Handle) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetStreamingMode(ANSCENTER::ANSLLM** Handle, int streamingMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetStreamingMode: HandlePtr=%p, *Handle=%p, streamingMode=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), streamingMode);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -617,6 +708,7 @@ extern "C" ANSLLM_API int ANSLLMSetStreamingMode(ANSCENTER::ANSLLM** Handle, in
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetIdleTimeoutMs(ANSCENTER::ANSLLM** Handle) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetIdleTimeoutMs: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return -1;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return -1;
|
||||
@@ -631,6 +723,8 @@ extern "C" ANSLLM_API int ANSLLMGetIdleTimeoutMs(ANSCENTER::ANSLLM** Handle) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetIdleTimeoutMs(ANSCENTER::ANSLLM** Handle, int idleTimeoutMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetIdleTimeoutMs: HandlePtr=%p, *Handle=%p, idleTimeoutMs=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), idleTimeoutMs);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -646,6 +740,8 @@ extern "C" ANSLLM_API int ANSLLMSetIdleTimeoutMs(ANSCENTER::ANSLLM** Handle, in
|
||||
}
|
||||
|
||||
extern "C" ANSLLM_API int ANSLLMSetSleepMs(ANSCENTER::ANSLLM** Handle, int sleepMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetSleepMs: HandlePtr=%p, *Handle=%p, sleepMs=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), sleepMs);
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -660,6 +756,7 @@ extern "C" ANSLLM_API int ANSLLMSetSleepMs(ANSCENTER::ANSLLM** Handle, int slee
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetLastErrorMessage(ANSCENTER::ANSLLM** Handle, LStrHandle LastErrorMessage) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetLastErrorMessage: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -674,6 +771,7 @@ extern "C" ANSLLM_API int ANSLLMGetLastErrorMessage(ANSCENTER::ANSLLM** Handle,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetOutputText(ANSCENTER::ANSLLM** Handle, LStrHandle outputText) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetOutputText: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -688,6 +786,7 @@ extern "C" ANSLLM_API int ANSLLMGetOutputText(ANSCENTER::ANSLLM** Handle, LStrH
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetOutputTextSb(ANSCENTER::ANSLLM** Handle, LStrHandle outputTextSb) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetOutputTextSb: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
if (Handle == nullptr || *Handle == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(*Handle));
|
||||
if (!guard) return 0;
|
||||
@@ -709,6 +808,8 @@ extern "C" ANSLLM_API int ANSLLMGetOutputTextSb(ANSCENTER::ANSLLM** Handle, LSt
|
||||
// ============================================================================
|
||||
|
||||
extern "C" ANSLLM_API int SetANSLLMProvider_V2(uint64_t handleVal, const char* provider) {
|
||||
ANS_DBG("ANSLLM","SetANSLLMProvider_V2: handleVal=%llu, provider=%s",
|
||||
(unsigned long long)handleVal, provider ? provider : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -723,6 +824,7 @@ extern "C" ANSLLM_API int SetANSLLMProvider_V2(uint64_t handleVal, const char*
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int GetANSLLMProvider_V2(uint64_t handleVal, LStrHandle provider) {
|
||||
ANS_DBG("ANSLLM","GetANSLLMProvider_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -737,6 +839,7 @@ extern "C" ANSLLM_API int GetANSLLMProvider_V2(uint64_t handleVal, LStrHandle p
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int SetApiKey_V2(uint64_t handleVal, const char* apiKey) {
|
||||
ANS_DBG("ANSLLM","SetApiKey_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -751,6 +854,7 @@ extern "C" ANSLLM_API int SetApiKey_V2(uint64_t handleVal, const char* apiKey)
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetModelList_V2(uint64_t handleVal, LStrHandle modelList) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetModelList_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -771,6 +875,8 @@ extern "C" ANSLLM_API int ANSLLMGetModelList_V2(uint64_t handleVal, LStrHandle
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetTranscriptMode_V2(uint64_t handleVal, int transcriptMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetTranscriptMode_V2: handleVal=%llu, transcriptMode=%d",
|
||||
(unsigned long long)handleVal, transcriptMode);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -785,6 +891,8 @@ extern "C" ANSLLM_API int ANSLLMSetTranscriptMode_V2(uint64_t handleVal, int tr
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetModel_V2(uint64_t handleVal, const char* modelName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetModel_V2: handleVal=%llu, modelName=%s",
|
||||
(unsigned long long)handleVal, modelName ? modelName : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -799,6 +907,7 @@ extern "C" ANSLLM_API int ANSLLMSetModel_V2(uint64_t handleVal, const char* mod
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddText_V2(uint64_t handleVal, const char* inputText) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddText_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -813,6 +922,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddText_V2(uint64_t handleVal, const char*
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageUrl_V2(uint64_t handleVal, const char* imageURL, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageUrl_V2: handleVal=%llu, imageURL=%s",
|
||||
(unsigned long long)handleVal, imageURL ? imageURL : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -828,6 +939,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageUrl_V2(uint64_t handleVal, const c
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageFromPath_V2(uint64_t handleVal, const char* filePath, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageFromPath_V2: handleVal=%llu, filePath=%s",
|
||||
(unsigned long long)handleVal, filePath ? filePath : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -843,6 +956,7 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageFromPath_V2(uint64_t handleVal, co
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddImageFromBase64_V2(uint64_t handleVal, const char* base64Image, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddImageFromBase64_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -858,6 +972,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddImageFromBase64_V2(uint64_t handleVal,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddFileURL_V2(uint64_t handleVal, const char* fileURL, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddFileURL_V2: handleVal=%llu, fileURL=%s",
|
||||
(unsigned long long)handleVal, fileURL ? fileURL : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -873,6 +989,8 @@ extern "C" ANSLLM_API int ANSLLMInputAddFileURL_V2(uint64_t handleVal, const ch
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMInputAddFileData_V2(uint64_t handleVal, const char* filePath, const char* summary) {
|
||||
ANS_DBG("ANSLLM","ANSLLMInputAddFileData_V2: handleVal=%llu, filePath=%s",
|
||||
(unsigned long long)handleVal, filePath ? filePath : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -888,6 +1006,7 @@ extern "C" ANSLLM_API int ANSLLMInputAddFileData_V2(uint64_t handleVal, const c
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMClearInput_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMClearInput_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -902,6 +1021,8 @@ extern "C" ANSLLM_API int ANSLLMClearInput_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMCreateConversation_V2(uint64_t handleVal, const char* systemMessage, const char* developerMessage, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMCreateConversation_V2: handleVal=%llu, conversationName=%s",
|
||||
(unsigned long long)handleVal, conversationName ? conversationName : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (systemMessage == nullptr || developerMessage == nullptr || conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -917,6 +1038,8 @@ extern "C" ANSLLM_API int ANSLLMCreateConversation_V2(uint64_t handleVal, const
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetConversation_V2(uint64_t handleVal, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetConversation_V2: handleVal=%llu, conversationName=%s",
|
||||
(unsigned long long)handleVal, conversationName ? conversationName : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -932,6 +1055,8 @@ extern "C" ANSLLM_API int ANSLLMSetConversation_V2(uint64_t handleVal, const ch
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMDeleteConversation_V2(uint64_t handleVal, const char* conversationName) {
|
||||
ANS_DBG("ANSLLM","ANSLLMDeleteConversation_V2: handleVal=%llu, conversationName=%s",
|
||||
(unsigned long long)handleVal, conversationName ? conversationName : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (conversationName == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -947,6 +1072,7 @@ extern "C" ANSLLM_API int ANSLLMDeleteConversation_V2(uint64_t handleVal, const
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetConversationList_V2(uint64_t handleVal, LStrHandle conversationList) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetConversationList_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -967,6 +1093,7 @@ extern "C" ANSLLM_API int ANSLLMGetConversationList_V2(uint64_t handleVal, LStr
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMAsk_V2(uint64_t handleVal, const char* prompt, LStrHandle response) {
|
||||
ANS_DBG("ANSLLM","ANSLLMAsk_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (prompt == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -982,6 +1109,8 @@ extern "C" ANSLLM_API int ANSLLMAsk_V2(uint64_t handleVal, const char* prompt,
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMPollAi_V2(uint64_t handleVal, int abort) {
|
||||
ANS_DBG("ANSLLM","ANSLLMPollAi_V2: handleVal=%llu, abort=%d",
|
||||
(unsigned long long)handleVal, abort);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -996,6 +1125,8 @@ extern "C" ANSLLM_API int ANSLLMPollAi_V2(uint64_t handleVal, int abort) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetUTF8_V2(uint64_t handleVal, int utf8Mode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetUTF8_V2: handleVal=%llu, utf8Mode=%d",
|
||||
(unsigned long long)handleVal, utf8Mode);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1010,6 +1141,7 @@ extern "C" ANSLLM_API int ANSLLMSetUTF8_V2(uint64_t handleVal, int utf8Mode) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetUTF8_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetUTF8_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1024,6 +1156,8 @@ extern "C" ANSLLM_API int ANSLLMGetUTF8_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetLocalLLM_V2(uint64_t handleVal, int localLLM) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetLocalLLM_V2: handleVal=%llu, localLLM=%d",
|
||||
(unsigned long long)handleVal, localLLM);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1038,6 +1172,8 @@ extern "C" ANSLLM_API int ANSLLMSetLocalLLM_V2(uint64_t handleVal, int localLLM
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetOllamaBaseUrl_V2(uint64_t handleVal, const char* baseUrl) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetOllamaBaseUrl_V2: handleVal=%llu, baseUrl=%s",
|
||||
(unsigned long long)handleVal, baseUrl ? baseUrl : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (baseUrl == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -1053,6 +1189,8 @@ extern "C" ANSLLM_API int ANSLLMSetOllamaBaseUrl_V2(uint64_t handleVal, const c
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetBaseURL_V2(uint64_t handleVal, const char* baseURL) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetBaseURL_V2: handleVal=%llu, baseURL=%s",
|
||||
(unsigned long long)handleVal, baseURL ? baseURL : "(null)");
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
if (baseURL == nullptr) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
@@ -1068,6 +1206,8 @@ extern "C" ANSLLM_API int ANSLLMSetBaseURL_V2(uint64_t handleVal, const char* b
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetHeartbeatMs_V2(uint64_t handleVal, int heartbeatMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetHeartbeatMs_V2: handleVal=%llu, heartbeatMs=%d",
|
||||
(unsigned long long)handleVal, heartbeatMs);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1082,6 +1222,7 @@ extern "C" ANSLLM_API int ANSLLMSetHeartbeatMs_V2(uint64_t handleVal, int heart
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetHeartbeatMs_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetHeartbeatMs_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return -1;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return -1;
|
||||
@@ -1096,6 +1237,8 @@ extern "C" ANSLLM_API int ANSLLMGetHeartbeatMs_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetHostedConversation_V2(uint64_t handleVal, int hostedConversationMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetHostedConversation_V2: handleVal=%llu, hostedConversationMode=%d",
|
||||
(unsigned long long)handleVal, hostedConversationMode);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1110,6 +1253,7 @@ extern "C" ANSLLM_API int ANSLLMSetHostedConversation_V2(uint64_t handleVal, in
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetHostedConversation_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetHostedConversation_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1124,6 +1268,7 @@ extern "C" ANSLLM_API int ANSLLMGetHostedConversation_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetStreamingMode_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetStreamingMode_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1138,6 +1283,8 @@ extern "C" ANSLLM_API int ANSLLMGetStreamingMode_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetStreamingMode_V2(uint64_t handleVal, int streamingMode) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetStreamingMode_V2: handleVal=%llu, streamingMode=%d",
|
||||
(unsigned long long)handleVal, streamingMode);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1152,6 +1299,7 @@ extern "C" ANSLLM_API int ANSLLMSetStreamingMode_V2(uint64_t handleVal, int str
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetIdleTimeoutMs_V2(uint64_t handleVal) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetIdleTimeoutMs_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return -1;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return -1;
|
||||
@@ -1166,6 +1314,8 @@ extern "C" ANSLLM_API int ANSLLMGetIdleTimeoutMs_V2(uint64_t handleVal) {
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetIdleTimeoutMs_V2(uint64_t handleVal, int idleTimeoutMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetIdleTimeoutMs_V2: handleVal=%llu, idleTimeoutMs=%d",
|
||||
(unsigned long long)handleVal, idleTimeoutMs);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1180,6 +1330,8 @@ extern "C" ANSLLM_API int ANSLLMSetIdleTimeoutMs_V2(uint64_t handleVal, int idl
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMSetSleepMs_V2(uint64_t handleVal, int sleepMs) {
|
||||
ANS_DBG("ANSLLM","ANSLLMSetSleepMs_V2: handleVal=%llu, sleepMs=%d",
|
||||
(unsigned long long)handleVal, sleepMs);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1194,6 +1346,7 @@ extern "C" ANSLLM_API int ANSLLMSetSleepMs_V2(uint64_t handleVal, int sleepMs)
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetLastErrorMessage_V2(uint64_t handleVal, LStrHandle LastErrorMessage) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetLastErrorMessage_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1208,6 +1361,7 @@ extern "C" ANSLLM_API int ANSLLMGetLastErrorMessage_V2(uint64_t handleVal, LStr
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetOutputText_V2(uint64_t handleVal, LStrHandle outputText) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetOutputText_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
@@ -1222,6 +1376,7 @@ extern "C" ANSLLM_API int ANSLLMGetOutputText_V2(uint64_t handleVal, LStrHandle
|
||||
}
|
||||
}
|
||||
extern "C" ANSLLM_API int ANSLLMGetOutputTextSb_V2(uint64_t handleVal, LStrHandle outputTextSb) {
|
||||
ANS_DBG("ANSLLM","ANSLLMGetOutputTextSb_V2: handleVal=%llu", (unsigned long long)handleVal);
|
||||
auto* _v2h = reinterpret_cast<ANSCENTER::ANSLLM*>(handleVal); if (!_v2h) return 0;
|
||||
LLMHandleGuard guard(AcquireLLMHandle(_v2h));
|
||||
if (!guard) return 0;
|
||||
|
||||
Reference in New Issue
Block a user