Skip to content

Commit

Permalink
Merge branch 'main' into add-explain-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
jaresty authored Aug 15, 2024
2 parents 359f792 + e98c2d0 commit cccc6be
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions GPT/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions GPT/gpt.talon
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@
{user.model} [nope] that was <user.text>$:
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()
3 changes: 2 additions & 1 deletion lib/modelHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions lib/modelState.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cccc6be

Please sign in to comment.