developer README

The project's README from github.com/smol-ai/developer. As one markdown file: README.md.

🐣 smol developer

Deploy agent on e2b button Morph Morph

Human-centric & Coherent Whole Program Synthesis aka your own personal junior developer

Build the thing that builds the thing! a smol dev for every dev in every situation

This is a "junior developer" agent (aka smol dev) that either:

  1. scaffolds an entire codebase out for you once you give it a product spec
  2. gives you basic building blocks to have a smol developer inside of your own app.

Instead of making and maintaining specific, rigid, one-shot starters, like create-react-app, or create-nextjs-app, this is basically is or helps you make create-anything-app where you develop your scaffolding prompt in a tight loop with your smol dev.

After the successful initial v0 launch, smol developer was rewritten to be even smol-ler, and importable from a library!

Basic Usage

In Git Repo mode

# install
git clone https://github.com/smol-ai/developer.git
cd developer
poetry install # install dependencies. pip install poetry if you need

# run
python main.py "a HTML/JS/CSS Tic Tac Toe Game" # defaults to gpt-4-0613
# python main.py "a HTML/JS/CSS Tic Tac Toe Game" --model=gpt-3.5-turbo-0613

# other cli flags
python main.py --prompt prompt.md # for longer prompts, move them into a markdown file
python main.py --prompt prompt.md --debug True # for debugging
This lets you develop apps as a human in the loop, as per the original version of smol developer.

engineering with prompts, rather than prompt engineering

The demo example in prompt.md shows the potential of AI-enabled, but still firmly human developer centric, workflow:

  • Human writes a basic prompt for the app they want to build
  • main.py generates code
  • Human runs/reads the code
  • Human can:
    • simply add to the prompt as they discover underspecified parts of the prompt
    • manually runs the code and identifies errors
    • paste the error into the prompt just like they would file a GitHub issue
    • for extra help, they can use debugger.py which reads the whole codebase to make specific code change suggestions

Loop until happiness is attained. Notice that AI is only used as long as it is adding value - once it gets in your way, just take over the codebase from your smol junior developer with no fuss and no hurt feelings. (we could also have smol-dev take over an existing codebase and bootstrap its own prompt... but that's a Future Direction)

In this way you can use your clone of this repo itself to prototype/develop your app.

In Library mode

This is the new thing in smol developer v1! Add smol developer to your own projects!

pip install smol_dev

Here you can basically look at the contents of main.py as our "documentation" of how you can use these functions and prompts in your own app:

from smol_dev.prompts import plan, specify_file_paths, generate_code_sync

prompt = "a HTML/JS/CSS Tic Tac Toe Game"

shared_deps = plan(prompt) # returns a long string representing the coding plan

# do something with the shared_deps plan if you wish, for example ask for user confirmation/edits and iterate in a loop

file_paths = specify_file_paths(prompt, shared_deps) # returns an array of strings representing the filenames it needs to write based on your prompt and shared_deps. Relies on OpenAI's new Function Calling API to guarantee JSON.

# do something with the filepaths if you wish, for example display a plan

# loop through file_paths array and generate code for each file
for file_path in file_paths:
    code = generate_code_sync(prompt, shared_deps, file_path) # generates the source code of each file

    # do something with the source code of the file, eg. write to disk or display in UI
    # there is also an async `generate_code()` version of this

In API mode (via Agent Protocol)

To start the server run:

poetry run api

or

python smol_dev/api.py

and then you can call the API using either the following commands:

To create a task run:

curl --request POST \
  --url http://localhost:8000/agent/tasks \
  --header 'Content-Type: application/json' \
  --data '{
	"input": "Write simple script in Python. It should write '\''Hello world!'\'' to hi.txt"
}'

You will get a response like this:

{"input":"Write simple script in Python. It should write 'Hello world!' to hi.txt","task_id":"d2c4e543-ae08-4a97-9ac5-5f9a4459cb19","artifacts":[]}

Then to execute one step of the task copy the task_id you got from the previous request and run:

curl --request POST \
  --url http://localhost:8000/agent/tasks/<task-id>/steps

or you can use Python client library:

from agent_protocol_client import AgentApi, ApiClient, TaskRequestBody

...

prompt = "Write simple script in Python. It should write 'Hello world!' to hi.txt"

async with ApiClient() as api_client:
    # Create an instance of the API class
    api_instance = AgentApi(api_client)
    task_request_body = TaskRequestBody(input=prompt)

    task = await api_instance.create_agent_task(
        task_request_body=task_request_body
    )
    task_id = task.task_id
    response = await api_instance.execute_agent_task_step(task_id=task_id)

...

I'm actively seeking more examples, please PR yours!

sorry for the lack of examples, I know that is frustrating but I wasnt ready for so many of you lol

major forks/alternatives

please send in alternative implementations, and deploy strategies on alternative stacks!

innovations and insights

Please subscribe to https://latent.space/ for a fuller writeup and insights and reflections

Please subscribe to https://latent.space/ for a fuller writeup and insights and reflections

caveats

We were working on a Chrome Extension, which requires images to be generated, so we added some usecase specific code in there to skip destroying/regenerating them, that we haven't decided how to generalize.

We dont have access to GPT4-32k, but if we did, we'd explore dumping entire API/SDK documentation into context.

The feedback loop is very slow right now (time says about 2-4 mins to generate a program with GPT4, even with parallelization due to Modal (occasionally spiking higher)), but it's a safe bet that it will go down over time (see also "future directions" below).

future directions

things to try/would accept open issue discussions and PRs:

developer (smol-ai/developer)

Searching Database…

12.2K ·GitHub
Что это такое?smol developer — это ИИ-агент «младший разработчик», который либо создаёт весь каркас кодовой базы по описанию продукта, либо может встраиваться в ваше приложение как библиотека для генерации кода.
Это инструмент командной строки, библиотека или и то, и другое?И то, и другое: его можно запустить в режиме Git Repo как рабочий процесс командной строки с участием человека через main.py, импортировать в свой проект как библиотеку Python или запустить как сервер, который предоставляет API Agent Protocol.
Как мне это запустить?Опишите нужное приложение в промпте в файле prompt.md, затем запустите main.py, чтобы сгенерировать код; проверьте его, запустите и пошагово дополняйте промпт или вставляйте обратно сообщения об ошибках, чтобы исправить проблемы. В режиме API запустите сервер и создавайте и запускайте задачи через API Agent Protocol или клиент на Python.
Нужен ли мне ключ API OpenAI, чтобы пользоваться этим?Да, он использует GPT-4 (а в демо для некоторых примеров упоминается Anthropic Claude), а для запуска ИИ-вызовов с повторными попытками и распараллеливанием применяет Modal.
Какие главные ограничения на данный момент?Согласованность всей программы между файлами пока несовершенна, так как shareddependencies.md не всегда фиксирует жёсткие зависимости; цикл обратной связи медленный (2–4 минуты на одну генерацию даже с распараллеливанием); и пока он не может сам устанавливать свои зависимости или исправлять ошибки, возникающие во время работы.
Для чего нужен инструмент debugger.py?Он читает всю сгенерированную кодовую базу вместе с сообщением об ошибке и предлагает конкретные исправления кода; в README его называют особенно полезным для отладки проблем синтеза всей программы.
Почему в README сказано, что нужен только Markdown?Markdown естественным образом сочетает обычный английский текст и блоки кода, поэтому он идеально подходит для промптов, описывающих всю программу целиком: GPT-4 надёжно следует коду, вложенному в промпты в Markdown.
Есть ли реализации на других языках?Да, в README приведены сторонние форки на JS/TS, C#/.NET и Golang, а также инструмент, который автоматически генерирует плагины OpenAI из спецификации API в формате Markdown в стиле smol developer.
Можно ли работать с уже существующей кодовой базой, а не генерировать с нуля?Пока не полностью: в README в качестве будущего направления указано создание prompt.md на основе существующей кодовой базы («smol pm»), но сейчас это работает не очень хорошо.
Creator
smol-ai
Size
0.2 MB
Stars
12.2K
Updated
CommitSep 25
Age
3y
Commits · 90 Days