diff --git a/GPT/gpt.py b/GPT/gpt.py index 78eea4fc..a33c65bc 100644 --- a/GPT/gpt.py +++ b/GPT/gpt.py @@ -90,6 +90,14 @@ def gpt_generate_sql(text_to_process: str) -> str: "text", "" ) + def gpt_start_debug(): + """Enable debug logging""" + GPTState.start_debug() + + def gpt_stop_debug(): + """Disable debug logging""" + GPTState.stop_debug() + def gpt_clear_context(): """Reset the stored context""" GPTState.clear_context() diff --git a/GPT/gpt.talon b/GPT/gpt.talon index 4efd076d..8ea9b99a 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} start debug: user.gpt_start_debug() + +# Disable debug logging +{user.model} stop debug: user.gpt_stop_debug() diff --git a/lib/modelHelpers.py b/lib/modelHelpers.py index 47def25c..25ea7e4f 100644 --- a/lib/modelHelpers.py +++ b/lib/modelHelpers.py @@ -177,7 +177,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 da53198d..b34745cb 100644 --- a/lib/modelState.py +++ b/lib/modelState.py @@ -13,6 +13,19 @@ class GPTState: context: ClassVar[list[GPTMessageItem]] = [] thread: ClassVar[list[GPTMessage]] = [] thread_enabled: ClassVar[bool] = False + debug_enabled: ClassVar[bool] = False + + @classmethod + def start_debug(cls): + """Enable debug printing""" + GPTState.debug_enabled = True + actions.app.notify("Enabled debug logging") + + @classmethod + def stop_debug(cls): + """Disable debug printing""" + GPTState.debug_enabled = False + actions.app.notify("Disabled debug logging") @classmethod def clear_context(cls):