Skip to content

Detecting file media type before submitting binary content to LLM, a small Kotlin multiplatform library.

License

Notifications You must be signed in to change notification settings

xemantic/xemantic-ai-file-magic

Repository files navigation

xemantic-ai-file-magic

Detecting file content type before submitting binary content to LLM, a small Kotlin multiplatform library.

Maven Central Version GitHub Release Date license

GitHub Actions Workflow Status GitHub branch check runs GitHub commits since latest release GitHub last commit

GitHub contributors GitHub commit activity GitHub code size in bytes GitHub Created At kotlin version

discord server discord users online X (formerly Twitter) Follow

Why?

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-magic was initially a part of the anthropic-sdk-kotlin, but was eventually externalized, as a common functionality applicable across various API-related use cases.

Usage

In build.gradle.kts add:

dependencies {
  implementation("com.xemantic.ai:xemantic-ai-file-magic:0.2")
}

See test cases for further information.

Development

Clone this repo and then in the project dir:

./gradlew build

About

Detecting file media type before submitting binary content to LLM, a small Kotlin multiplatform library.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Languages