diff --git a/GPT/gpt.py b/GPT/gpt.py index c32906c1..03a57a02 100644 --- a/GPT/gpt.py +++ b/GPT/gpt.py @@ -91,6 +91,14 @@ def gpt_generate_sql(text_to_process: str) -> str: "text", "" ) + def gpt_enable_debug(): + """Enable debug logging""" + GPTState.enable_debug() + + def gpt_disable_debug(): + """Disable debug logging""" + GPTState.disable_debug() + def gpt_clear_context(): """Reset the stored context""" GPTState.clear_context() diff --git a/GPT/gpt.talon b/GPT/gpt.talon index 4efd076d..421d0d86 100644 --- a/GPT/gpt.talon +++ b/GPT/gpt.talon @@ -23,3 +23,9 @@ {user.model} [nope] that was $: result = user.gpt_reformat_last(text) user.paste(result) + +# Enable debug logging so you can more details about messages being sent +{user.model} enable debug: user.gpt_enable_debug() + +# Disable debug logging +{user.model} disable debug: user.gpt_disable_debug() diff --git a/lib/modelHelpers.py b/lib/modelHelpers.py index b111ee20..0b3acea2 100644 --- a/lib/modelHelpers.py +++ b/lib/modelHelpers.py @@ -174,7 +174,8 @@ def send_request( "n": 1, "model": settings.get("user.openai_model"), } - + if GPTState.debug_enabled: + print(data) if tools is not None: data["tools"] = tools diff --git a/lib/modelState.py b/lib/modelState.py index ec5fb2a7..c8adab6c 100644 --- a/lib/modelState.py +++ b/lib/modelState.py @@ -12,6 +12,19 @@ class GPTState: context: ClassVar[list[GPTMessageItem]] = [] thread: ClassVar[list[GPTMessage]] = [] thread_enabled: ClassVar[bool] = False + debug_enabled: ClassVar[bool] = False + + @classmethod + def enable_debug(cls): + """Enable debug printing""" + cls.context = [] + actions.app.notify("Enabled debug logging") + + @classmethod + def disable_debug(cls): + """Disable debug printing""" + cls.context = [] + actions.app.notify("Disabled debug logging") @classmethod def clear_context(cls):