smol-ai / developer

the first library to let you embed a developer agent in your own app!
https://twitter.com/SmolModels
MIT License
11.79k stars 1.03k forks source link

Generated code files contain markdown and other non-code text #100

Open ndepal opened 1 year ago

ndepal commented 1 year ago

I'm trying out smol developer for the first time and I've come across the issue that the code files generated contain parts of the response that is not actually code. Namely the tree backticks to start and end a code bloc are included in the source file. In some instances, it also includes plain text sentences that should not be part of the source files.

This minimal example shows the issue:

Prompt:

modal run main.py --prompt 'A python program that calls a function called hello, which takes an argument of a person to greet. After the function call, the program exits with code 0. The program is saved in `main.py`.'

The resulting source file main.py:

Here's the code for main.py:

```python
def hello(person):
    print("Hello, " + person + "!")

hello("John Doe")
exit(0)

This code defines a function called hello that takes a single argument person and prints a greeting to the console. It then calls the hello function with the argument "John Doe" and exits the program with code 0.



Only the part between the three backticks should have been saved in `main.py`.

Is there something I can add to the prompt to prevent this from happening?