Skip to content

Commit

Permalink
Remove extract-sources command
Browse files Browse the repository at this point in the history
May revisit this in the future, but in the meantime it is extra maintenance
cost while upgrading other things.
  • Loading branch information
nicovank committed Nov 30, 2023
1 parent c050dbf commit a4c18d7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
3 changes: 0 additions & 3 deletions src/cwhy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ def main():
subparsers.add_parser("explain", help="explain the diagnostic (default)")
subparsers.add_parser("fix", help="propose a fix for the diagnostic")
subparsers.add_parser("diff", help="propose a fix in diff format")
subparsers.add_parser(
"extract-sources", help="extract the source locations from the diagnostic"
)

parser.set_defaults(subcommand="explain")

Expand Down
20 changes: 0 additions & 20 deletions src/cwhy/cwhy.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ def evaluate(args, stdin):
return evaluate_text_prompt(args, fix_prompt(args, stdin))
elif args["subcommand"] == "diff":
return evaluate_diff(args, stdin).choices[0].message.function_call.arguments
elif args["subcommand"] == "extract-sources":
return evaluate_text_prompt(args, extract_sources_prompt(stdin), wrap=False)
else:
raise Exception(f"unknown subcommand: {args['subcommand']}")

Expand Down Expand Up @@ -350,24 +348,6 @@ def fix_prompt(args, diagnostic):
)


class extract_sources_context:
def __init__(self, diagnostic):
diagnostic_lines = diagnostic.splitlines()
line = min(len(diagnostic_lines) - 1, 50)
self.diagnostic = "```\n" + "\n".join(diagnostic_lines[:line]) + "\n```\n"


def extract_sources_prompt(diagnostic):
ctx = extract_sources_context(diagnostic)
user_prompt = "Respond only in the CSV format with no header row.\n"
user_prompt += "Identify all of the file paths and associated line numbers.\n"
user_prompt += "Output each file path and associated line number.\n"
user_prompt += "\n"
user_prompt += ctx.diagnostic

return user_prompt


def wrapper(args):
process = subprocess.run(
[args["wrapper_compiler"], *sys.argv[1:]],
Expand Down

0 comments on commit a4c18d7

Please sign in to comment.