Skip to content

Commit

Permalink
Update lm.py
Browse files Browse the repository at this point in the history
  • Loading branch information
okhat authored Oct 8, 2024
1 parent 4ef3841 commit 069808f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dspy/clients/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def __init__(self, model, model_type="chat", temperature=0.0, max_tokens=1000, c
self.model = model
self.model_type = model_type
self.cache = cache
self.temperature = temperature
self.max_tokens = max_tokens
self.kwargs = kwargs
self.kwargs = dict(temperature=temperature, max_tokens=max_tokens, **kwargs)
self.history = []

if "o1-" in model:
Expand All @@ -35,7 +33,7 @@ def __call__(self, prompt=None, messages=None, **kwargs):
# Build the request.
cache = kwargs.pop("cache", self.cache)
messages = messages or [{"role": "user", "content": prompt}]
kwargs = {"temperature": self.temperature, "max_tokens": self.max_tokens, **self.kwargs, **kwargs}
kwargs = {**self.kwargs, **kwargs}

# Make the request and handle LRU & disk caching.
if self.model_type == "chat":
Expand All @@ -59,6 +57,7 @@ def __call__(self, prompt=None, messages=None, **kwargs):
model_type=self.model_type,
)
self.history.append(entry)

return outputs

def inspect_history(self, n: int = 1):
Expand Down

0 comments on commit 069808f

Please sign in to comment.