-
Notifications
You must be signed in to change notification settings - Fork 737
Inject env var in headers + better type annotations #3142
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
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 improves the agent configuration handling by injecting environment variable values into request headers where needed and enhancing type annotations.
- Updated _load_agent_config to use the new AgentConfig type.
- Added a new types file with detailed type definitions for various server configurations.
- Modified CLI logic to support env variable injections for both stdio and HTTP/SSE servers with improved type hints.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/huggingface_hub/inference/_mcp/utils.py | Updated type annotations for agent configuration and added import for AgentConfig |
src/huggingface_hub/inference/_mcp/types.py | Introduced comprehensive TypedDict definitions for various server configurations |
src/huggingface_hub/inference/_mcp/cli.py | Refactored env/headers injection logic and adjusted type usage with ignore comments |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
||
class HTTPServer(TypedDict): | ||
type: Literal["http"] | ||
config: HTTPServerConfig |
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.
i think we should switch now to the standard server config schema https://code.visualstudio.com/docs/copilot/chat/mcp-servers and remove the nested config
, wdyt?
cc @julien-c
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.
yep probably... (no super strong opinion)
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.
thank you, the PR looks good! I think we can merge this one and do a patch release (to iterate faster on this) and then open a separate PR to switch to the standard server config schema and include that in the next minor release of huggingface_hub
.
* Inject env var in headers + better type annotations * fix lint * fix thanks to copilot
@hanouticelina done https://github.com/huggingface/huggingface_hub/releases/tag/v0.32.5 |
Follow-up of #3129 and Python equivalent of the second part of huggingface/huggingface.js#1501.
With this PR, input variables are also injected in requestInit headers if required by the config (basically this implementation). See #3129 (comment) as well.
Also this PR adds better type annotation for the agent config. Helps a bit the IDE / autocompletions.