Skip to content

armgit / dspy

Public Imported from GitHub
0

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.py
index 320432fdd..570133de0 100644
--- a/dsp/modules/lm.py
+++ b/dsp/modules/lm.py
@@ -5,15 +5,11 @@ from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Literal, Optional
-@dataclass#(frozen=True) technically should be frozen
class 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 = []
@abstractmethod
def basic_request(self, prompt, **kwargs):