feat: OpenAI-compat /v1/embeddings endpoint + bug fixes (v0.3.0)#4
Merged
Conversation
Add OpenAI-compatible embedding endpoint so Graphiti (and any OpenAI SDK client) can route through OQP without reconfiguration. New: - openai_compat.py: path detection (is_openai_compat_path), path rewrite (/v1/embeddings → /api/embed), and response wrapping (Ollama → OpenAI embeddings format). Always-on; no config required. - proxy_handler: detect /v1/embeddings, rewrite path before enqueue, wrap response after dispatch. Cache and auth apply unchanged. - _enqueue_request / dispatch_request: add path_override param for compat path rewrite to propagate through queue/cache/dispatch logic. - 14 new tests covering path detection, rewrite, response wrapping, and list-index env var skip behavior. Bug fixes: - main.py: asyncio.get_event_loop() → get_running_loop() (DeprecationWarning in 3.10+, RuntimeError in 3.12+) - proxy.py: streaming generator now closes httpx response in finally block to prevent connection leak on client disconnect - config.py: _apply_env_overrides now skips any key with a numeric path component instead of crashing with TypeError when the target is a list (e.g. OQP_OLLAMA__HOSTS__0__URL) Bump version to 0.3.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…edundant import - openai_compat.py: rewrite_path() now returns "/api/embed" (was "api/embed") — missing slash produced malformed URLs like "http://host:11434api/embed" - proxy.py: comment on stream_gen finally block — explains it closes the httpx connection on client disconnect to prevent connection leak (not obvious from code) - main.py: comment on get_running_loop() — explains why get_event_loop() was replaced (deprecated 3.10+, raises RuntimeError in 3.12+) - main.py: remove local `import json as _json` inside proxy_handler — json is already imported at module level; use it directly - test_openai_compat.py: update expected values to match corrected "/api/embed" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add endpoint to the Endpoints table and a dedicated section explaining the translation, Graphiti config snippet, and that it is always-on. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /v1/embeddingsendpoint that translates to/api/embedinternally — enables Graphiti (and any OpenAI SDK client) to route through OQP without changing its provider configopenai_compat.pymodule handles path detection, rewrite, and Ollama→OpenAI response format wrappingasyncio.get_event_loop()deprecation in Python 3.10+ (→get_running_loop())finally: await r.aclose())_apply_env_overridescrash (TypeError: list indices must be integers) when env var contains a numeric path component (e.g.OQP_OLLAMA__HOSTS__0__URL)Test plan
pytest tests/passes 150/150 (14 new + 136 existing)curl -X POST http://localhost:11435/v1/embeddings -d '{"model":"bge-m3","input":"test"}'returns OpenAI format/v1/embeddings/v1/embeddingsreturns 401Note: After this PR merges and CI passes, tag
v0.3.0to trigger GHCR publish. Then update forgeagent-platform/docker-compose.ymltov0.3.0and reconfigure Graphiti (separate helm-build task).🤖 Generated with Claude Code