Skip to content

Conversation

@chenmoneygithub
Copy link
Collaborator

@chenmoneygithub chenmoneygithub commented Oct 8, 2024

As litellm becomes an official dependency of DSPy, we no longer need the hacky import handling code.

Also reformat the code for better readability.

@chenmoneygithub chenmoneygithub requested a review from okhat October 8, 2024 00:23

class LM:
def __init__(self, model, model_type='chat', temperature=0.0, max_tokens=1000, cache=True, **kwargs):
def __init__(self, model, model_type="chat", temperature=0.0, max_tokens=1000, cache=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chen! Why remove kwargs? The kwargs here are important. They're at the level of the LM object. The kwargs in__call__ are at the level of the individual call. Both are needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh the kwargs is not really used in __init__ method, and the only place it is used is inside __call__ method, where we join it with kwargs of __call__ method. This is not ideal because we are not drawing an explicit boundary between these two kwargs, so users don't know which one they should use. We might want to explicitly list out model args like temperature and max_tokens for clarity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @chenmoneygithub ! It's important that users can set kwargs in __init__, which become defaults for __call__. The kwargs passed to __call__ overwrite any defaults from __init__. It was well-defined and commonly used. We should add it back IMO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing! Let me add it back.

@chenmoneygithub chenmoneygithub requested a review from okhat October 8, 2024 05:25
self.kwargs = dict(temperature=temperature, max_tokens=max_tokens, **kwargs)
self.temperature = temperature
self.max_tokens = max_tokens
self.kwargs = kwargs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be:

        self.kwargs = dict(temperature=temperature, max_tokens=max_tokens, **kwargs)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was cleaner?

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

Successfully merging this pull request may close these issues.

2 participants