Skip to content

armgit / dspy

Public Imported from GitHub
0

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.py
index 55da51588..ade241793 100644
--- a/dsp/modules/gpt3.py
+++ b/dsp/modules/gpt3.py
@@ -14,6 +14,7 @@ import functools
import json
from typing import Any, Literal, Optional, cast
+import dsp
import backoff
import openai
import 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"]