Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

fix(dspy): prompt_eval_count occasionally is None and causes TypeError

371258aa68c81c7e8f
diff --git a/dsp/modules/ollama.py b/dsp/modules/ollama.py
index 3ea025c8a..9e696e509 100644
--- a/dsp/modules/ollama.py
+++ b/dsp/modules/ollama.py
@@ -133,7 +133,7 @@ class OllamaLocal(LM):
"finish_reason": "stop",
},
)
- tot_eval_tokens += response_json.get("eval_count")
+ tot_eval_tokens += response_json.get("eval_count", self._prev_prompt_eval_count)
request_info["additional_kwargs"] = {k: v for k, v in response_json.items() if k not in ["response"]}
request_info["usage"] = {