
Enables automatic detection of file content types for binary data, streamlining API interactions by setting MIME types and encoding data as base64 strings for AI platforms.
Detecting file media type before submitting binary content to LLM, a small Kotlin multiplatform library.
The APIs of AI companies, like OpenAI API and Anthropic API, are accepting binary content, (e.g. images and documents), encoded as base64 strings with accompanied MIME type. This library provides a minimal support of detecting the MediaType of binary data, therefore it simplifies API usage, so that only a file is referenced directly, and all the other parameters can be detected and set automatically.
[!NOTE] The
xemantic-ai-file-magicwas initially a part of the anthropic-sdk-kotlin, but was eventually externalized, as a common functionality applicable across various API-related use cases.
In build.gradle.kts add:
dependencies {
implementation("com.xemantic.ai:xemantic-ai-file-magic:0.4.0")
}See test cases for further information.
Clone this repo and then in the project dir:
./gradlew buildDetecting file media type before submitting binary content to LLM, a small Kotlin multiplatform library.
The APIs of AI companies, like OpenAI API and Anthropic API, are accepting binary content, (e.g. images and documents), encoded as base64 strings with accompanied MIME type. This library provides a minimal support of detecting the MediaType of binary data, therefore it simplifies API usage, so that only a file is referenced directly, and all the other parameters can be detected and set automatically.
[!NOTE] The
xemantic-ai-file-magicwas initially a part of the anthropic-sdk-kotlin, but was eventually externalized, as a common functionality applicable across various API-related use cases.
In build.gradle.kts add:
dependencies {
implementation("com.xemantic.ai:xemantic-ai-file-magic:0.4.0")
}See test cases for further information.
Clone this repo and then in the project dir:
./gradlew build