MCPcopy
hub / github.com/LAION-AI/Open-Assistant / CodeBugger

Class CodeBugger

scripts/data_augment/data_augment.py:360–391  ·  view source on GitHub ↗

https://github.com/LAION-AI/Open-Assistant/blob/main/notebooks/code-bugger/openbugger_example.md Openbugger is a Python package that allows you to inject syntax and logic errors into your code. This can be useful for testing the robustness of your code or for creating test cases for deb

Source from the content-addressed store, hash-verified

358
359
360class CodeBugger(DataAugmenter):
361 """
362 https://github.com/LAION-AI/Open-Assistant/blob/main/notebooks/code-bugger/openbugger_example.md
363 Openbugger is a Python package that allows you to inject syntax and logic errors into your code.
364 This can be useful for testing the robustness of your code or for creating test cases for debugging exercises or for training an assistant to debug code.
365 To install:
366 cwd = os.getcwd()
367
368 # Next, we'll use Git to clone the repository.
369 subprocess.run(["git", "clone", "https://github.com/furlat/OpenBugger", cwd + "/OpenBugger"])
370
371 # Now, we'll use pip to install the package from the local repository.
372 subprocess.run(["python3", "-m", "pip", "install", "--editable", cwd + "/OpenBugger"])
373 """
374
375 def __init__(self):
376 self.syntax_bug = SyntaxBug()
377 self.logic_bug = LogicBug()
378
379 def parse_single(self, code):
380 code = self.syntax_bug(code, "medium", num_errors=2)
381 code = self.logic_bug(code, "medium", num_errors=2)
382
383 question = "Can you fix the following code?\n" + code
384
385 answer = (
386 "The following code is correct:\n"
387 + code
388 + "\nI hope I could help you fixing your code. In case you need more help, feel free to ask me again."
389 )
390
391 return [question], [answer]
392
393
394class CodeInstructor(DataAugmenter):

Callers 1

get_augmenterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected