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: signature does not match between interface and implementations #17

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

Comments

@inspiralpatterns
Copy link
Collaborator

def generate(self):

One of the main points of having an interface is that all implementations for an abstract method will match the function signature of the abstract method. This way, you will be able to be generic in high-level functions (read: dependency inversion) and at the same make sure that you can swap all subclasses of BaseLLM without breaking the code (read: Liskov Substitution Principle).

@stoyan-stoyanov
Copy link
Owner

the problem is that different LLMs can and will have different arguments when generating. E.g. a regular LLM will just need a prompt(str) while a ChatLLM will require a conversation history. And these might differ even more when we start adding LLMs from APIs other than OpenAI

@inspiralpatterns
Copy link
Collaborator Author

Then you might want to take a look at the strategy pattern: you do not change the function signature of an interface in its implementation - it takes the whole concept of having an interface away.

@stoyan-stoyanov
Copy link
Owner

Note: Check strategy pattern & protocol class

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

2 participants