-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: add passing http_client to components using OpenAI clients #9170
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?
feat: add passing http_client to components using OpenAI clients #9170
Conversation
I would like to add tests of using def test_init_with_proxy_in_http_client_by_env(self, monkeypatch):
monkeypatch.setenv('HTTP_PROXY', 'http://user:password@my-proxy.com:8080')
monkeypatch.setenv('HTTPS_PROXY', 'https://user:password@my-proxy.com:4433')
embedder = OpenAITextEmbedder(
api_key=Secret.from_token('fake-api-key'),
)
proxies_with_auth_headers = {
(str(mount._pool._proxy_url.origin), mount._pool._proxy_headers[0][1])
for mount in embedder.client._client._mounts.values()
}
assert proxies_with_auth_headers == {
('http://my-proxy.com:8080', b'Basic dXNlcjpwYXNzd29yZA=='),
('https://my-proxy.com:4433', b'Basic dXNlcjpwYXNzd29yZA=='),
} |
…o-openai # Conflicts: # haystack/components/embedders/openai_document_embedder.py # haystack/components/embedders/openai_text_embedder.py # haystack/components/generators/chat/openai.py
Hey @alexengrig thanks for this effort. Let's split it in a few PRs. Perhaps we can start with OpenAIChatGenerator only as a test pilot PR. Note that you seem to be using 3.10 syntax, we still need to support 3.9 so let's use that syntax still. Perhaps open a new PR for OpenAIChatGenerator only? |
Hi @vblagoje!
I agree, and I'll open it.
OK, I'll fix it. |
Hello! For serialization/deserialization purposes, I think we should allow passing |
Hi @alexengrig, |
@vblagoje
What should I do with the current PR, and how should I split the changes for the components into additional PRs? |
Related Issues
Proposed Changes:
When using components with an OpenAI client, we can configure the HTTP client by passing
http_client
.How did you test it?
I don’t have any ideas for suitable tests, could you suggest some tests that could be added?I added unit tests for the new parameter
http_client
.Notes for the reviewer
I would like to add documentation on using proxies, authentication, and HTTP_PROXY support, could you tell me where I should add this documentation?I added
HTTP_PROXY
as an example to the docstring.Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.