Skip to content

Commit 6082b1f

Browse files
committed
add docs command
1 parent f9c75f4 commit 6082b1f

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

codegpt/gpt_interface.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ def send_iffy_edit(prompt: str, code: Dict[str, str], clipboard: bool = False, y
5252
> <the code to be output line 1>
5353
> <the code to be output, line n...>
5454
55-
You must include an explanation of what you did, and the code to be output, regardless of the format or file.
56-
57-
OUTPUT:""")
55+
You must include an explanation of what you did, and the code to be output, regardless of the format or file.""")
5856

5957
else:
6058
full_prompt += dedent("""
@@ -71,9 +69,7 @@ def send_iffy_edit(prompt: str, code: Dict[str, str], clipboard: bool = False, y
7169
> <code line 1>
7270
> <code line n...>
7371
74-
You must include the filename, an explanation of what you did, and the code for the file to be output, regardless of the format or file.
75-
76-
OUTPUT:""")
72+
You must include the filename, an explanation of what you did, and the code for the file to be output, regardless of the format or file.""")
7773

7874
max_tokens = confirm_send(full_prompt, yes=yes, silent=clipboard)
7975

codegpt/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def edit_file(
8888
return
8989

9090
if raw_out:
91-
print(result['code'])
91+
print(result.get('code') or result)
9292
return
9393

9494
files.write_text(result, backup)

codegpt/parse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ def parse_resp(response:dict):
1717
# If the line doesn't start with '>', it's a key
1818
if line[0] != '>':
1919
# Strip leading/trailing whitespace and remove ':' from the key
20-
key = line.strip().replace(":", '')
20+
key = line.strip().replace(":", '').lower()
2121
# Initialize an empty value for this key in the current dictionary
2222
curr_dict[key] = ""
23+
else:
2324
curr_dict[key] += line.strip().strip('> ').strip('>') + '\n'
2425

2526
# Add the final dictionary to the output list

tests/test_edit_file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_edit_file_add_comment():
1212

1313
# Call the function being tested
1414
result = run.invoke(app, ['do', instruction, "--yes", "--raw-out", "--raw-code", f"'{raw_code}'"])
15-
15+
1616
# Use a regex to match the output of the function
1717
assert "#" in result.stdout
1818
assert "def foo():" in result.stdout
@@ -34,6 +34,8 @@ def test_varnames():
3434
# Call the function being tested
3535
result = run.invoke(app, ['do', instruction, "--yes", "--raw-out", "--raw-code", f"'{raw_code}'"])
3636

37+
print(result.stdout)
38+
3739
assert 'v0 = 0.2' in result.stdout
3840
assert 'a = 2' not in result.stdout
3941
assert 'n = 21' not in result.stdout

0 commit comments

Comments
 (0)