Currently it can work at function level, and can make reasonable modifications to existing code (sometimes buggy, but that may be fixable with a larger model and better training data).
The current chat UI isn't suitable for working with larger codebases, but it seems within realm of possibility to extend it to be an IDE like CoPilot with tooling that feeds it your whole codebase and documentation to work with.
A simple example, and not 'perfect', but it's quite impressive. Even a simple case of throwing your code 'over the wall' to the AI for review before going to an actual person is a huge time-saver.
The token size limit is the killer here, it means larger files, let alone projects, can't be fully processed in a single prompt.
Initial code produced: ``` def sum_of_digits(n):
if n == 0:
return 0
else:
return n % 10 + sum_of_digits(n // 10)
```I didn't save the exact code review, but essentially it was just a list of suggested code changes. The prompt was:
``` prompt = f'Python3. Act like you are a senior engineer writing a code review comment on the code. Write at least two specific changes to make, being sure to check for any errors first: {prompt}. Be as concise and correct as possible, and also be sure to write in a way that is easy to understand.
```
The resulting output code was:
``` import unittest
def sum_of_digits(n):
if n < 0: # Added base case check for negative numbers
return None
elif not isinstance(n, int): # Check type of argument passed in
raise TypeError("Input must be an integer")
elif n == 0:
return 0
else:
return n % 10 + sum_of_digits(n // 10)
# Unit tests using built-in test suiteclass TestSumOfDigits(unittest.TestCase):
def test_sum_of_digits_positive(self):
self.assertEqual(sum_of_digits(123), 6)
def test_sum_of_digits_negative(self):
self.assertEqual(sum_of_digits(-123), None)
def test_sum_of_digits_type(self):
with self.assertRaises(TypeError):
sum_of_digits('abc')
if __name__ == '__main__':unittest.main() ```
Edit: trying to cleanup hn formatting for readability
HN code formatting is simple, prefix each line with 2 spaces and then you don't need any extra blank lines like with normal paragraphs.
class TestSumOfDigits(unittest.TestCase):
def test_sum_of_digits_positive(self):
self.assertEqual(sum_of_digits(123), 6)
def test_sum_of_digits_negative(self):
self.assertEqual(sum_of_digits(-123), None)
def test_sum_of_digits_type(self):
with self.assertRaises(TypeError):
sum_of_digits('abc')
if __name__ == '__main__':
unittest.main()
``` does nothing, it's just noise here.