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

invalid syntax error "I understand. Here is a list of filepaths that you would need to create the program: " #66

Open ZakariyaMBA opened 1 year ago

ZakariyaMBA commented 1 year ago

The script seems to get hung up on an invalid syntax error when providing detailed requirements in the prompt. Also I have noticed that using "" and , in the prompt.md seems to throw the script off. Only keeping it simple without quotation marks or commas, the prompt executes.

The error:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in _run_module_as_main │ │ │ │ 195 │ │ sys.argv[0] = mod_spec.origin │ │ ❱ 196 │ return _run_code(code, main_globals, None, │ │ 197 │ │ │ │ │ "main", mod_spec) │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code │ │ │ │ 85 │ │ │ │ │ spec = mod_spec) │ │ ❱ 86 │ exec(code, run_globals) │ │ 87 │ return run_globals │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\Scripts\modal.exe__main.py:7 in │ │ │ │ │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\modal__main.py:6 │ │ in main │ │ │ │ 5 def main(): │ │ ❱ 6 │ entrypoint_cli() │ │ 7 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py:1130 in │ │ call__ │ │ │ │ 1129 │ │ """Alias for :meth:main.""" │ │ ❱ 1130 │ │ return self.main(*args, kwargs) │ │ 1131 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\typer\core.py:778 in │ │ main │ │ │ │ 777 │ ) -> Any: │ │ ❱ 778 │ │ return _main( │ │ 779 │ │ │ self, │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\typer\core.py:216 in │ │ _main │ │ │ │ 215 │ │ │ with self.make_context(prog_name, args, extra) as ctx: │ │ ❱ 216 │ │ │ │ rv = self.invoke(ctx) │ │ 217 │ │ │ │ if not standalone_mode: │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py:1657 in │ │ invoke │ │ │ │ 1656 │ │ │ │ with sub_ctx: │ │ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │ │ 1658 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py:1657 in │ │ invoke │ │ │ │ 1656 │ │ │ │ with sub_ctx: │ │ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │ │ 1658 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py:1404 in │ │ invoke │ │ │ │ 1403 │ │ if self.callback is not None: │ │ ❱ 1404 │ │ │ return ctx.invoke(self.callback, **ctx.params) │ │ 1405 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py:760 in │ │ invoke │ │ │ │ 759 │ │ │ with ctx: │ │ ❱ 760 │ │ │ │ return callback(*args, kwargs) │ │ 761 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\click\decorators.py:2 │ │ 6 in new_func │ │ │ │ 25 │ def new_func(*args, *kwargs): # type: ignore │ │ ❱ 26 │ │ return f(get_current_context(), args, kwargs) │ │ 27 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\site-packages\modal\cli\run.py:116 │ │ in f │ │ │ │ 115 │ │ │ else: │ │ ❱ 116 │ │ │ │ func(*args, **kwargs) │ │ 117 │ │ │ if app.function_invocations == 0: │ │ │ │ C:\Users\Node_01\Documents\copilot coding\developer\main_2.py:133 in main │ │ │ │ 132 │ try: │ │ ❱ 133 │ │ list_actual = ast.literal_eval(filepaths_string) │ │ 134 │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\ast.py:64 in literal_eval │ │ │ │ 63 │ if isinstance(node_or_string, str): │ │ ❱ 64 │ │ node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval') │ │ 65 │ if isinstance(node_or_string, Expression): │ │ │ │ C:\Users\Node_01\AppData\Local\Programs\Python\Python310\lib\ast.py:50 in parse │ │ │ │ 49 │ # Else it should be an int giving the minor version for 3.x. │ │ ❱ 50 │ return compile(source, filename, mode, flags, │ │ 51 │ │ │ │ _feature_version=feature_version) │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │ I understand. Here is a list of filepaths that you would need to create the program: │ │ ▲ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ SyntaxError: invalid syntax

mylesdebastion commented 1 year ago

I seem to be getting a similar error here: ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ c:\users\myles\appdata\local\programs\python\python39\lib\runpy.py:197 in _run_module_as_main │ │ │ │ 196 │ │ sys.argv[0] = mod_spec.origin │ │ ❱ 197 │ return _run_code(code, main_globals, None, │ │ 198 │ │ │ │ │ "__main__", mod_spec) │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\runpy.py:87 in _run_code │ │ │ │ 86 │ │ │ │ │ __spec__ = mod_spec) │ │ ❱ 87 │ exec(code, run_globals) │ │ 88 │ return run_globals │ │ │ │ C:\Users\myles\AppData\Local\Programs\Python\Python39\Scripts\modal.exe\__main__.py:7 in │ │ <module> │ │ │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\modal\__main__.py:6 in │ │ main │ │ │ │ 5 def main(): │ │ ❱ 6 │ entrypoint_cli() │ │ 7 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\core.py:1130 in │ │ __call__ │ │ │ │ 1129 │ │ """Alias for :meth:main.""" │ │ ❱ 1130 │ │ return self.main(*args, **kwargs) │ │ 1131 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\typer\core.py:778 in │ │ main │ │ │ │ 777 │ ) -> Any: │ │ ❱ 778 │ │ return _main( │ │ 779 │ │ │ self, │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\typer\core.py:216 in │ │ _main │ │ │ │ 215 │ │ │ with self.make_context(prog_name, args, **extra) as ctx: │ │ ❱ 216 │ │ │ │ rv = self.invoke(ctx) │ │ 217 │ │ │ │ if not standalone_mode: │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\core.py:1657 in │ │ invoke │ │ │ │ 1656 │ │ │ │ with sub_ctx: │ │ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │ │ 1658 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\core.py:1657 in │ │ invoke │ │ │ │ 1656 │ │ │ │ with sub_ctx: │ │ ❱ 1657 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │ │ 1658 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\core.py:1404 in │ │ invoke │ │ │ │ 1403 │ │ if self.callback is not None: │ │ ❱ 1404 │ │ │ return ctx.invoke(self.callback, **ctx.params) │ │ 1405 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\core.py:760 in │ │ invoke │ │ │ │ 759 │ │ │ with ctx: │ │ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │ │ 761 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\click\decorators.py:26 │ │ in new_func │ │ │ │ 25 │ def new_func(*args, **kwargs): # type: ignore │ │ ❱ 26 │ │ return f(get_current_context(), *args, **kwargs) │ │ 27 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\site-packages\modal\cli\run.py:116 in │ │ f │ │ │ │ 115 │ │ │ else: │ │ ❱ 116 │ │ │ │ func(*args, **kwargs) │ │ 117 │ │ │ if app.function_invocations == 0: │ │ │ │ D:\Github\developer\main.py:129 in main │ │ │ │ 128 │ try: │ │ ❱ 129 │ │ list_actual = ast.literal_eval(filepaths_string) │ │ 130 │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\ast.py:62 in literal_eval │ │ │ │ 61 │ if isinstance(node_or_string, str): │ │ ❱ 62 │ │ node_or_string = parse(node_or_string, mode='eval') │ │ 63 │ if isinstance(node_or_string, Expression): │ │ │ │ c:\users\myles\appdata\local\programs\python\python39\lib\ast.py:50 in parse │ │ │ │ 49 │ # Else it should be an int giving the minor version for 3.x. │ │ ❱ 50 │ return compile(source, filename, mode, flags, │ │ 51 │ │ │ │ _feature_version=feature_version) │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Here is a list of filepaths that could be used to create the web app: │ │ ▲ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ SyntaxError: invalid syntax

ktunprasert commented 1 year ago

I managed to get it working by adding extra to the filepaths system prompt

    filepaths_string = generate_response(
        """You are an AI developer who is trying to write a program that will generate code for the user based on their intent.

    When given their intent, create a complete, exhaustive list of filepaths that the user would write to make the program.

    only list the filepaths you would write, and return them as a python list of strings.
    do not add any other explanation, only return a python list of strings.

    Don't respond with description messages or helper messages. If you're going to list the file don't offer "here's a list" only list the filepaths
    """,

The final line saying "Don't respond..." is what I added