Repository navigation
libmoss v0.33.0
·
5 commits
to main
since this release
Precompiled C SDK binaries for the Moss SDK.
Added
moss_client_new_with_options,moss_client_new_with_device_id_and_options,moss_client_new_with_authenticator_and_optionsandmoss_client_new_with_authenticator_device_id_and_optionstake the arguments ofmoss_client_new,moss_client_new_with_device_id,moss_client_new_with_authenticatorandmoss_client_new_with_authenticator_and_device_id, plus aconst MossClientOptions *beforeout. NULL options are the defaults, which the constructors without options use. Zero aMossClientOptions, then setstruct_sizetosizeof(MossClientOptions)andversiontoMOSS_CLIENT_OPTIONS_VERSION, 1. A smallerstruct_size, another version or an unknown flag bit fails withERR_INVALID_ARG. TheMOSS_CLIENT_OPTIONS_FLAG_KEEP_MODELSflag, off by default, keeps each model the client loads after the last client or session that uses it is freed, for later clients of the same project in the process, until the grant it was opened under is within 30 seconds of expiring. A client created then loads a cached index without opening the model again, once its own grant for the same artifact arrives. The flag works on every platform, iOS and Android included.moss_client_release_memoryfrees at once each kept model that no client or session holds. With a NULL client it frees only those models and writes 0 toout_unloaded, instead of failing withERR_NULL_POINTER, so a host can answer memory pressure while no client is open.
Changed
- Breaking change:
moss_client_sessionandmoss_client_session_v2fail when the load of the cloud index of the same name fails, with that load's code, and leave*outNULL. For example,ERR_CLOUDwhen the Moss cloud cannot be reached,ERR_UNAUTHORIZEDwhen the service rejects the credentials or the project is over its usage limit,ERR_INVALID_ARGwhen the service refuses the index's model artifact with HTTP 409, andERR_DESERIALIZATIONwhen the artifact's provenance is malformed or does not match the downloaded index. They used to log the failure and return an empty session, which a latermoss_session_push_indexcould push over the cloud index. An index that does not exist yet, or a name the cloud cannot address, still opens an empty session.MOSS_SESSION_OPTIONS_V2_FLAG_SKIP_AUTO_LOAD_ON_INITonmoss_client_session_v2skips the load, whichmoss_client_sessioncannot; unlessmodel_idiscustom, opening still checks the project credentials, which a client with a project key does over the network. moss_set_model_cache_dir()installs the panic hook, asmoss_sdk_version()does, so a host that never asks for the version still gets the panic message inmoss-panic.login the model cache directory. A panic aborts the process, as it did before, and the README says so under Error Handling.- A client or session that reuses an embedding model another client of the project holds, or one that
MOSS_CLIENT_OPTIONS_FLAG_KEEP_MODELSkept, now asks the issuer for its own grant first. That adds one round trip and still skips the decrypt and session start. A client the issuer refuses now fails to load the model instead of using one another client opened.
Fixed
- A session keeps its saved snapshot to itself while it serves vectors from it, also after
moss_session_save_to_diskwrites a new generation.moss_session_load_from_diskandmoss_session_save_to_diskof the same session name and cache path in a second session, in this process or another, fail withERR_INTERNALand the message "The saved session snapshot is open in another session." until the first session is freed. A save used to replace the file that held the lock, so after one save a second session could load and save the same snapshot beside the first and overwrite its saves. The lock is the filesession.lockin the session's directory, and it holds on Windows too. Loading from a directory this process cannot write works when the snapshot already has itssession.lock, which every save writes, and fails otherwise. A snapshot that an earlier version saved has none. Add an emptysession.lockfile to its directory, or load a copy: while nothing saves to the snapshot, copy its directory under the same name into another directory, make the copy writable by the process, and pass that other directory as the cache path. On iOS and Android, a.mossvecthatmoss_client_load_indexmaps fromcache_pathis locked through a.lockfile beside it. A second client that loads the same index from the samecache_pathwhile the first holds it does not fail: it keeps that index's vectors in memory instead of mapping the file. Earlier versions take neither lock file, so a process on one of them and a process on this version do not lock each other out. Keep every process on an earlier version stopped while a process on this version has the same cache path open. - A client, session or
MossInferencebuilt beforefork()works in the forked child instead of hanging there. The child starts a runtime of its own for it on first use, and an inference client its own connections too, keeps the indexes the parent loaded, and starts its own telemetry. A child whose runtime fails to start with an I/O error fails that call withERR_INTERNAL, and its next call tries again. A fork while another thread is inside a call on the same client or session is not supported. A query in a forked child no longer waits forever once the parent has run a query.
Platforms
| Archive | OS | Arch |
|---|---|---|
libmoss-v0.33.0-aarch64-apple-darwin.tar.gz |
macOS | ARM64 (Apple Silicon) |
libmoss-v0.33.0-x86_64-unknown-linux-gnu.tar.gz |
Linux | x86_64 |
libmoss-v0.33.0-aarch64-unknown-linux-gnu.tar.gz |
Linux | ARM64 |
libmoss-v0.33.0-x86_64-pc-windows-msvc.tar.gz |
Windows | x86_64 |
Contents
Each archive contains:
include/libmoss.h- C headerlib/libmoss.dylib,lib/libmoss.soorlib/moss.dll- shared libraryLICENSE.txt- the license of the libraryLICENSE-THIRD-PARTY.txt- licenses of the third-party code the library links
Windows archives also contain the DLL import library lib/moss.dll.lib.
License
The library is licensed under the PolyForm Shield License 1.0.0, not under this repository's BSD 2-Clause License.
Required Notice: Copyright InferEdge Inc. (https://inferedge.dev)
Usage
Extract, then compile and link. The macOS dylib ships with an
@rpath/libmoss.dylib install name, so pass an -rpath that
resolves to lib/ or the binary aborts at launch with
"Library not loaded: @rpath/libmoss.dylib ... no LC_RPATH's found":
# macOS
clang your_app.c -o your_app -Iinclude -Llib -lmoss \
-Wl,-rpath,@loader_path/lib \
-framework Security -framework SystemConfiguration
# Linux
gcc your_app.c -o your_app -Iinclude -Llib -lmoss -lpthread -lm -ldl