DSPy: The framework for programming—not prompting—language models
Python
added logging support only if enabled in settings
Arnav Singhvic06a4f38882f
diff --git a/dsp/modules/gpt3.py b/dsp/modules/gpt3.pyindex 55da51588..ade241793 100644--- a/dsp/modules/gpt3.py+++ b/dsp/modules/gpt3.py@@ -14,6 +14,7 @@ import functoolsimport jsonfrom typing import Any, Literal, Optional, cast+import dspimport backoffimport openaiimport openai.error@@ -169,7 +170,8 @@ class GPT3(LM):# kwargs = {**kwargs, "logprobs": 5}response = self.request(prompt, **kwargs)- self.log_usage(response)+ if dsp.settings.log_openai_usage:+ self.log_usage(response)choices = response["choices"]completed_choices = [c for c in choices if c["finish_reason"] != "length"]