Skip to content
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

ChatCompletionClient.load_component support default-headers #5163

Open
zhangshan123 opened this issue Jan 23, 2025 · 2 comments
Open

ChatCompletionClient.load_component support default-headers #5163

zhangshan123 opened this issue Jan 23, 2025 · 2 comments
Milestone

Comments

@zhangshan123
Copy link

zhangshan123 commented Jan 23, 2025

What feature would you like to be added?

ChatCompletionClient.load_component support default-headers

Why is this needed?

When I use AzureOpenAIChatCompletionClient and pass the below parameters, the code is working fine,
model_client = AzureOpenAIChatCompletionClient(
model = "gpt-4o-2024-05-13",
azure_deployment= 'xxxxxx',
azure_endpoint = 'xxxxxx',
api_version = 'xxxx',
api_key = os.getenv("AZURE_API_KEY"),
default_headers = {'X-User-Id': os.getlogin()}
)
but when I use ChatCompletionClient.load_component, and pass the config:
{'provider': 'AzureOpenAIChatCompletionClient', 'config': {'model': 'xxxxx', 'azure_endpoint': 'xxxx', 'azure_deployment': 'xxxxx', 'api_version': 'xxxx', 'api_key': 'xxxxx', 'default_headers': {'X-User-Id': 'xxxxxx'}}}
it seems there is no way can pass the default_headers property, so meet the below error:
openai.PermissionDeniedError: Error code: 403 - {'error': {'code': '403', 'message': 'The X-User-Id request header is now mandatory for cost allocation. Please set the parameter with "xxxxx" for allocating to the end user's department or "srv_xxxx" for background jobs.'}}

@zhangshan123
Copy link
Author

zhangshan123 commented Jan 24, 2025

When I add default_headers property in AzureOpenAIClientConfigurationConfigModel, it can work fine.
class AzureOpenAIClientConfigurationConfigModel(BaseOpenAIClientConfigurationConfigModel):
# Azure specific
azure_endpoint: str
azure_deployment: str | None = None
api_version: str
azure_ad_token: str | None = None
azure_ad_token_provider: ComponentModel | None = None
default_headers: dict | None = None

@ekzhu
Copy link
Collaborator

ekzhu commented Jan 24, 2025

Would you like to submit a PR to fix this? The default header property is currently not part of the serialized config.

We need to modify this:

class BaseOpenAIClientConfigurationConfigModel(CreateArgumentsConfigModel):
model: str

to include default_headers

@ekzhu ekzhu modified the milestones: 0.4.4, 0.4.x Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants