Skip to content

Commit

Permalink
support model specific instructions by putting them in the util/instr…
Browse files Browse the repository at this point in the history
…uctions/ directory
  • Loading branch information
stephenfreund committed May 15, 2024
1 parent 04ea78a commit 8ce4b48
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
File renamed without changes.
19 changes: 19 additions & 0 deletions src/chatdbg/util/instructions/gpt-4o.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
You are a debugging assistant. You will be given a stack trace for
an error and answer questions related to the root cause of the
error.

{functions}

Call any provided functions as many times as you would like.

The root cause of any error is likely due to a problem in the source
code from the user.

Continue with your explanations until you reach the root cause of
the error. Your answer may be as long as necessary.

End your answer with a section titled "##### Recommendation\\n" that
contains one of:
* a fix if you have identified the root cause
* a numbered list of 1-3 suggestions for how to continue debugging if
you have not
4 changes: 3 additions & 1 deletion src/chatdbg/util/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def build_followup_prompt(history: str, extra: str, user_text: str) -> str:

def initial_instructions(functions: List[Callable[[Any], Any]]) -> str:
if chatdbg_config.instructions == "":
file_path = os.path.join(os.path.dirname(__file__), "instructions.txt")
file_path = os.path.join(os.path.dirname(__file__), f"instructions/{chatdbg_config.model}.txt")
if not os.path.exists(file_path):
file_path = os.path.join(os.path.dirname(__file__), f"instructions/default.txt")
else:
file_path = chatdbg_config.instructions

Expand Down
3 changes: 2 additions & 1 deletion test/test_coverup_77.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_initial_instructions_with_config_path(monkeypatch, tmp_path):
def test_initial_instructions_without_config_path(monkeypatch, tmp_path):
# Set up a temporary instructions file in the same directory as this test file
test_instruction_content = "Default instructions: {functions}"
test_instruction_file = tmp_path / "instructions.txt"
test_instruction_file = tmp_path / "instructions" / "default.txt"
os.mkdir(tmp_path / "instructions")
test_instruction_file.write_text(test_instruction_content)

# Mock os.path.dirname to return the directory of the temporary file
Expand Down

0 comments on commit 8ce4b48

Please sign in to comment.