DSPy: The framework for programming—not prompting—language models
Python
Remove dataclass from LM
Isaac Miller3fc1449b81ac
diff --git a/dsp/modules/lm.py b/dsp/modules/lm.pyindex 320432fdd..570133de0 100644--- a/dsp/modules/lm.py+++ b/dsp/modules/lm.py@@ -5,15 +5,11 @@ from copy import deepcopyfrom dataclasses import dataclass, fieldfrom typing import Any, Literal, Optional-@dataclass#(frozen=True) technically should be frozenclass LM(ABC):"""Abstract class for language models."""- kwargs: dict[str, Any] = field(init=False)- provider: str = field(init=False)- history: list[dict[str, Any]] = field(init=False)def __init__(self, model):- object.__setattr__(self, 'kwargs', {+ self.kwargs = {"model": model,"temperature": 0.0,"max_tokens": 150,@@ -21,9 +17,9 @@ class LM(ABC):"frequency_penalty": 0,"presence_penalty": 0,"n": 1,- })- object.__setattr__(self, 'provider', "default")- object.__setattr__(self, 'history', [])+ }+ self.provider = "default"+ self.history = []@abstractmethoddef basic_request(self, prompt, **kwargs):