Skip to content

Commit 71595c0

Browse files
committed
fix: minor update on the instruction prompts
1 parent cee824b commit 71595c0

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

script/parse.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44
import ast
55
import json
66
import zipfile
7-
import base64
87
import shutil
98
from glob import glob
109
from pprint import pprint
1110
from tqdm import tqdm
12-
import folium
13-
import geopy
14-
import librosa
15-
import Crypto
16-
1711

1812
def extract_apis(code):
1913
tree = ast.parse(code)
@@ -306,8 +300,8 @@ def extract_content(file_path, rename_id=None, task_id=None):
306300
# get the nearest "def" before docstring_start
307301
function_name_start = content.rfind("def", 0, docstring_start)
308302
data["signature"] = " ".join(l.strip() for l in content[function_name_start:docstring_start].strip().splitlines())
309-
data["prompt"] = content[:docstring_end + 3]
310-
data["prompt_wo_doc"] = "\n".join(line for line in content[:docstring_start].strip().splitlines() if line)
303+
data["prompt"] = content[:docstring_end + 3] + "\n"
304+
data["prompt_wo_doc"] = "\n".join(line for line in content[:docstring_start].strip().splitlines() if line) + "\n"
311305
# print(data["prompt"])
312306
tree = ast.parse(content)
313307
function_end_line = None
@@ -414,7 +408,7 @@ def parse_docstring(docstring):
414408
return sections
415409

416410
def reconstruct_problem(data):
417-
return data["prompt"] + "\n" + data["clean_canonical_solution"] + "\n\n" + data["test"] + "\n"
411+
return data["prompt"] + data["clean_canonical_solution"] + "\n\n" + data["test"] + "\n"
418412

419413
def get_instruction_prompt(data):
420414
base = "Write a function called " + f'`{data["signature"]}` to: ' + " ".join(data["doc"]["description"])
@@ -423,7 +417,7 @@ def get_instruction_prompt(data):
423417
if data["doc"]["raises"]:
424418
base += "\nThe function should raise the exception for: " + " ".join(data["doc"]["raises"])
425419
base += "\nThe function should output with:\n " +\
426-
"\n ".join(data["doc"]["returns"]) + "\nYou should start with:\n```\n" + data["prompt_wo_doc"] + "\n```"
420+
"\n ".join(data["doc"]["returns"]) + "\nYou should start with:\n```\n" + data["prompt_wo_doc"] + "```"
427421
return base
428422

429423
def check_test_wo_doc(data):

0 commit comments

Comments
 (0)