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

refactor: use config classes instead of input arguments #7

Closed
inspiralpatterns opened this issue Jul 12, 2023 · 3 comments
Closed

refactor: use config classes instead of input arguments #7

inspiralpatterns opened this issue Jul 12, 2023 · 3 comments

Comments

@inspiralpatterns
Copy link
Collaborator

model: str = "text-davinci-003",
temperature: float = 0.7,
max_tokens: int = 500,
max_retries: int = 3,
api_key: Union[str, None] = None,

In such cases, I would appreciate having a dataclass, pydantic.BaseModel, or protocol like OpenAIConfig so that I avoid having tons of input arguments for class initialisation. Furthermore, you can also fully validate the configs and catch input errors early in your code.

@stoyan-stoyanov
Copy link
Owner

don't you think this way is more explicit and easier to read?

@vickychudinov
Copy link
Collaborator

I think it depends on the number and nature of arguments. If we have more than say 5-6 then a dataclass is justified, below that - its easier the way you have it.

@inspiralpatterns
Copy link
Collaborator Author

don't you think this way is more explicit and easier to read?

I agree to some extent, however, if you make it into a dataclass or a pydantic class you will also gain validation out of the box. Moreover, if you decide to use configuration files to set these parameters, you will gain serialisation and deserialisation out of the box.

@stoyan-stoyanov stoyan-stoyanov closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants