-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add runtime extra HTTP headers support #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds runtime-configurable HTTP headers support for LLM providers, enabling use cases like Cloudflare Access authentication. The PR also includes streaming with tools functionality from PR #94.
Key Changes:
- Added
extra_headers()builder method to configure runtime HTTP headers - Implemented
chat_stream_with_tools()for streaming responses with tool call support - Added
StreamChunkenum for unified streaming events (text, tool calls, completion)
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/builder.rs |
Added extra_headers field and builder method; passed to OpenAI and Cohere backends |
src/providers/openai_compatible.rs |
Stored extra_headers field; applied headers to all chat/streaming requests; implemented chat_stream_with_tools() with SSE parsing |
src/backends/openai.rs |
Passed extra_headers to provider; added extra_headers to hosted tools endpoint; delegated chat_stream_with_tools() to provider |
src/backends/mistral.rs |
Added None for extra_headers parameter (not exposed) |
src/backends/groq.rs |
Added None for extra_headers parameter (not exposed) |
src/backends/cohere.rs |
Added None for extra_headers parameter (not exposed) |
src/backends/huggingface.rs |
Added None for extra_headers parameter (not exposed) |
src/backends/openrouter.rs |
Added None for extra_headers parameter (not exposed) |
src/backends/anthropic.rs |
Implemented chat_stream_with_tools() with Anthropic-specific SSE parsing; handles empty tool arguments correctly |
src/chat/mod.rs |
Added StreamChunk enum and chat_stream_with_tools() trait method |
src/resilient_llm.rs |
Added resilient wrappers for new streaming methods |
tests/test_backends.rs |
Added comprehensive integration tests for streaming with tools (Anthropic backend) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @nazq, thanks for your work. Could you resolve the conflict? |
|
Sure. Give me a couple hours |
33aff7d to
ae26883
Compare
Done |
Add extra_headers option to LLMBuilder for custom HTTP headers in all requests. Useful for custom authentication like Cloudflare Access tokens. - Add extra_headers field and builder method to LLMBuilder - Add extra_headers to OpenAICompatibleProvider and apply in all request methods - Pass extra_headers from builder through OpenAI backend - Update all other OpenAI-compatible backends with None default - Add unit tests for extra_headers functionality
ae26883 to
198ad7a
Compare
Summary
extra_headers()builder method toLLMBuilderfor runtime-configurable HTTP headersNote: This PR is based on #94 (streaming with tools support) because the new
chat_stream_with_tools()methods also make HTTP requests that need extra headers support.Use Case
Changes
src/builder.rs- Addedextra_headersfield and builder methodsrc/providers/openai_compatible.rs- Store and apply extra headers in requestssrc/backends/openai.rs- Pass extra headers to providerNonefor compatibilityTest plan