Stop ignoring if not mentioned
Closed this issue · 0 comments
chadwhitacre commented
Lines 50 to 79 in 8638979
if 'issue' not in event: | |
return HttpResponseBadRequest('Malformed POST body - no issue') | |
if 'number' not in event['issue']: | |
return HttpResponseBadRequest('Malformed POST body - no issue number') | |
if 'body' not in event['issue']: | |
return HttpResponseBadRequest('Malformed POST body - no issue body') | |
body = event['issue']['body'] or '' # body can be None | |
issue_number = event['issue']['number'] | |
all_lines = body.splitlines() | |
if len(all_lines) < 3: | |
return HttpResponseBadRequest('Too few lines') | |
filespec = filespec_re.match(all_lines[0]) | |
if filespec is None: | |
return HttpResponseBadRequest('Malformed filespec') | |
sha, filepath, start, end = filespec.groups() | |
start, end = map(int, (start, end)) | |
instruction = '\n'.join(all_lines[2:]) | |
if not instruction.startswith('robb-oat'): | |
return JsonResponse({ | |
'ignored': 'not mentioned' | |
}) | |
content_url = f'https://raw.githubusercontent.com/{org_repo}/{sha}/{filepath}' | |
content_lines = httpx.get(content_url).text.splitlines() | |
before = '\n'.join(content_lines[:start-1]) | |
old_passage = '\n'.join(content_lines[start-1:end]) | |
after = '\n'.join(content_lines[end:]) | |
answer = openai.Edit.create(model='code-davinci-edit-001', input=old_passage, instruction=instruction) | |
new_passage = answer['choices'][0]['text'] | |
new_content = before + new_passage + after |
robb-oat Remove the check for whether robb-oat is mentioned.