You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update version to 0.3.1 and update DSPyMator documentation and LM param
- Bumped version from 0.3.0 to 0.3.1 in `pyproject.toml`.
- Added detailed configuration instructions for language models in `dspymator.md`, including usage examples for both string identifiers and pre-configured `dspy.LM` objects.
- Updated parameter references to clarify the handling of `temperature` and `max_tokens` when using `dspy.LM` objects.
DSPyMator accepts either a model string or a pre-configured `dspy.LM` object for the `lm` parameter.
253
+
254
+
**Simple usage with model string:**
255
+
256
+
```python
257
+
# Uses default OpenAI API (requires OPENAI_API_KEY env var)
258
+
classifier = DSPyMator(
259
+
program=dspy.Predict("text -> label"),
260
+
target_names="label",
261
+
lm="openai/gpt-4o-mini",
262
+
temperature=0.0,
263
+
max_tokens=1000,
264
+
)
265
+
```
266
+
267
+
**Using custom providers:**
268
+
269
+
For custom API configuration, pass a pre-configured `dspy.LM` object. DSPy uses [LiteLLM](https://docs.litellm.ai/) under the hood, so any LiteLLM-supported provider works. Extra kwargs are passed through to LiteLLM:
270
+
271
+
```python
272
+
import dspy
273
+
274
+
# Pass a pre-configured LM object
275
+
classifier = DSPyMator(
276
+
program=dspy.Predict("text -> label"),
277
+
target_names="label",
278
+
lm=dspy.LM(
279
+
"openrouter/anthropic/claude-3-haiku",
280
+
temperature=0.1,
281
+
max_tokens=1000,
282
+
# Additional kwargs are passed to LiteLLM
283
+
),
284
+
)
285
+
```
286
+
287
+
!!! note "Temperature and max_tokens"
288
+
When passing a `dspy.LM` object, configure `temperature` and `max_tokens` on the LM directly. The DSPyMator parameters are ignored when using a pre-configured LM.
289
+
290
+
**Environment variables:**
291
+
292
+
Most providers are configured via environment variables. Set them before calling `fit()`:
293
+
294
+
```python
295
+
import os
296
+
297
+
# OpenAI
298
+
os.environ["OPENAI_API_KEY"] ="sk-..."
299
+
300
+
# OpenRouter
301
+
os.environ["OPENROUTER_API_KEY"] ="sk-or-..."
302
+
303
+
# Anthropic
304
+
os.environ["ANTHROPIC_API_KEY"] ="sk-ant-..."
305
+
```
306
+
307
+
See the [DSPy LM documentation](https://dspy.ai/api/models/LM/) and [LiteLLM provider docs](https://docs.litellm.ai/docs/providers) for supported providers and configuration.
308
+
250
309
### Async Execution for Speed
251
310
252
311
By default, DSPyMator uses async execution for faster batch predictions:
0 commit comments