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
feat: widen support of env vars in OpenAI components #7653
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.
Thanks for the PR!
Any reason why we don't also add these settings as __init__
parameter? In other words, we could have
def __init__(
self,
...
timeout: float = 30.0,
max_retries: int = 5
):
then in the method:
...
self.client = OpenAI(
api_key=api_key.resolve_value(),
organization=organization,
base_url=api_base_url,
timeout=float(os.environ.get("OPENAI_TIMEOUT", timeout)),
max_retries=int(os.environ.get("OPENAI_MAX_RETRIES", max_retries)),
)
Don't you think it would be better to make the priority order this way: PARAMETER -> ENV_VAR -> DEFAULT Where -> Means overwrites. |
@CarlosFerLo yes please go ahead as you suggest! |
Merge branch 'issue-7610' of https://github.com/carlosFerLo/haystack into issue-7610
Pull Request Test Coverage Report for Build 9102969524Details
💛 - Coveralls |
Related Issues
Proposed Changes:
Now you can change the timeout and max retries of your OpenAI clients (
OpenAIDocumentEmbedder
,OpenAITextEmbedder
,OpenAIGenerator
andOpenAIChatGenerator
) just by using theOPENAI_TIMEOUT
andOPENAI_MAX_RETRIES
environment variables.How did you test it?
Enriched the unit tests of all this classes to test how this variables can be set.
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
. ✅