Skip to content

Implement encoding_format injection plugin for bifrost embedding requests - #1

Merged
lukoerfer merged 3 commits into
mainfrom
copilot/add-embedding-model-interceptor-plugin
Mar 27, 2026
Merged

lukoerfer merged 3 commits into
mainfrom
copilot/add-embedding-model-interceptor-plugin

Conversation

Copilot AI commented Mar 27, 2026 •

Copy link
Copy Markdown
Contributor

Some downstream LLM providers (e.g. older LiteLLM versions) require encoding_format in embedding requests, but upstream platforms like Open WebUI often omit it. This plugin intercepts embedding calls at the HTTP transport layer and injects the parameter when missing or null.

Plugin logic (main.go)

  • Rewrote hello-world example into a functional HTTPTransportPreHook that detects embedding endpoints via path matching and uses gjson/sjson for zero-allocation JSON inspection and mutation of the []byte request body
  • Supports float (default) and base64 encoding formats, configurable via plugin config
  • Passes through non-embedding requests and requests with encoding_format already set

Configuration

plugins:
  - name: encoding-format
    enabled: true
    path: /path/to/encoding-format.so
    config:
      encoding_format: "float"  # or "base64"

CI/CD (.github/workflows/build.yml)

  • Builds and tests on push/PR to main targeting Linux AMD64
  • Publishes .so binary to GitHub Releases on v* tag push via softprops/action-gh-release
  • Explicit least-privilege permissions scoping

Other changes

  • Updated go.mod module path to github.com/lukoerfer/bifrost-encoding-format-plugin
  • Updated Makefile plugin name to encoding-format
  • Added 15 unit tests covering init, path matching, injection, null replacement, and skip scenarios
  • Rewrote README.md with usage and configuration docs

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add plugin to intercept calls and set encoding_format Implement encoding_format injection plugin for bifrost embedding requests Mar 27, 2026
Copilot AI requested a review from lukoerfer March 27, 2026 23:35
@lukoerfer
lukoerfer marked this pull request as ready for review March 27, 2026 23:38
@lukoerfer
lukoerfer merged commit f6902cc into main Mar 27, 2026
2 checks passed
@lukoerfer
lukoerfer deleted the copilot/add-embedding-model-interceptor-plugin branch March 27, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants