AI Agent Hub
AI エージェント / プラグイン情報メディア
← 一覧へ
smol developer
OTHER

smol developer

smol developer

「あなた専用のジュニアエンジニア」をコンセプトにしたミニマル実装。スクラッチからプロジェクト雛形を生成する初期世代の代表 OSS。

原文: the first library to let you embed a developer agent in your own app!
#code-gen#minimal
REPO STATS

リポジトリ統計

⭐ Stars
12.2k
🍴 Forks
1.1k
⚠️ Open Issues
85
🌿 Language
Python
📄 License
MIT
🕒 最終更新
2024.04.07 (2年前)
📅 公開日
2023.05.13
🌿 Branch
main
README

ドキュメント

— AI による自動翻訳 (2026.05.07 更新)

🐣 smol developer

e2b に agent をデプロイするボタン Morph Morph

人間中心的で一貫した全体プログラム合成。あなた自身のパーソナルジュニア開発者です。

ものを構築するものを構築しましょう! あらゆる状況で、すべての開発者のための smol dev

これは「ジュニア開発者」エージェント(別名 smol dev)であり、以下のいずれかを行います:

  1. 製品仕様を与えると、あなた用に完全なコードベースをスキャフォールドします
  2. あなた自身のアプリ内に smol developer を持つための基本的なビルディングブロックを提供します。

create-react-appcreate-nextjs-app のような特定の、硬い、ワンショットスターターを作成・保守する代わりに、これは基本的には create-anything-app です。あなたが smol dev と緊密なループで scaffolding プロンプトを開発します。

成功した最初の v0 リリースの後、smol developer はさらに小さく書き直され、ライブラリからインポート可能になりました!

基本的な使い方

Git リポジトリモードで

# 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
これにより、smol developer の元のバージョンに従って、人間がループ内でアプリを開発できます。

プロンプトエンジニアリングではなく、プロンプトでエンジニアリングする

prompt.md のデモ例は、AI 対応だが依然として堅牢な人間の開発者中心のワークフローの可能性を示しています:

  • 人間が構築したいアプリのための基本的なプロンプトを書きます
  • main.py がコードを生成します
  • 人間がコードを実行/読みます
  • 人間は以下ができます:
    • プロンプトの不完全な部分を発見した時点で、簡単にプロンプトに追加します
    • 手動でコードを実行してエラーを特定します
    • GitHub issue を提出するのと同じように、エラーをプロンプトに貼り付けます
    • 追加のサポートが必要な場合、コードベース全体を読んで具体的なコード変更の提案をする debugger.py を使用できます

幸せになるまでループします。AI は価値を加える限り使用されます。それがあなたの邪魔になったら、smol junior developer からコードベースを引き継ぎます。気軽に、何の問題もなく。(smol-dev に既存のコードベースを引き継がせ、独自のプロンプトをブートストラップさせることもできますが、それは将来の方向性です

このように、このリポジトリのクローンを使用して、アプリのプロトタイプ/開発ができます。

ライブラリモード内

これは smol developer v1 の新機能です!自分のプロジェクトに smol developer を追加できます。

pip install smol_dev

main.py の内容を見ることで、自分のアプリでこれらの関数とプロンプトをどのように使用できるかについての「ドキュメント」として確認できます。

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

API モード(Agent Protocol 経由)

サーバーを起動するには、以下を実行してください。

poetry run api

または

python smol_dev/api.py

その後、以下のコマンドのいずれかを使用して API を呼び出せます。

タスクを作成する には以下を実行してください。

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"
}'

次のようなレスポンスが返されます。

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

タスクの 1 ステップを実行する には、前のリクエストから取得した task_id をコピーして、以下を実行してください。

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

または、Python クライアントライブラリ を使用することもできます。

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)

...

examples/プロンプトギャラリー

より多くの例を積極的に探しています。あなたのものをPRしてください!

例が少なくて申し訳ありません。それがイライラしていることは分かっていますが、こんなに多くの皆さんに対応する準備ができていませんでした lol

主なフォーク・代替実装

代替実装やその他のスタックへのデプロイ戦略を送ってください!

イノベーションと洞察

https://latent.space/ の購読をお願いします。より詳細な解説や洞察、考察をご覧いただけます。

  • Markdown はすべてです - Markdown は、英語とコード(変数名 variable_names か完全な ``` コードフェンス付きコードサンプル)を簡単に混在できるため、プログラム全体の合成をプロンプトするのに完璧な方法です。
    • コード内のプロンプトでプロンプトを指定でき、GPT-4 がそれに厳密に従うことがわかりました。
  • コピペプログラミング
    • 新しい API(Anthropic API は GPT-3 の知識カットオフ以降)の周辺にコードを書く方法を、curl の入出力を貼り付けるだけでプログラムに理解させます。
    • エラーメッセージをプロンプトに貼り付け、それをどう処理するかをざっくり指示するようなものです。「ログブック駆動プログラミング」という感じですね。
  • cat でデバッグします - コードベース全体とエラーメッセージを一緒に、具体的な修正提案を得る。特に楽しいです!
  • プログラム全体の一貫性を取るコツ - 私たちが選んだ使用例である Chrome 拡張機能は、ファイル間に多くの間接的な依存関係があります。クロス依存関係の幻覚が生じると、プログラム全体がエラーになります。
    • GPT に shared_dependencies.md を考えさせる中間ステップを追加し、各ファイル生成時にそれを使うよう要求することで解決しました。基本的に GPT が自分自身と会話できるようになるということです…
    • …ただし、まだ完璧ではありません。shared_dependencies.md がファイル間のハード依存関係を完全に理解していないことがあります。そこでプロンプトで具体的な name を指定することで解決しました。最初は気が進みませんでしたが、うまくいきます。実は明確で曖昧性のないコミュニケーションを心がけているだけなんです。
    • prompt.md を参照して、SOTA smol-dev プロンプティングをご確認ください。
  • 不慣れな API への低い参入障壁
    • CSS アニメーションは本当には学んだことがありませんが、今は「juicy CSS アニメーションされた赤と白のキャンディストライプローディングインジケータ」が欲しいと言うだけで機能します。
    • Chrome Extension Manifest v3 も同様 - ドキュメントは絶望的に混乱していますが、幸い今は基本的なものを動かすためにドキュメントを読む必要がありません。
    • Anthropic のドキュメント(本当にひどい)には戻り値シグネチャについてのガイダンスがありませんでした。だから curl して、プロンプトに突っ込むだけです(笑)。
  • Modal はすべてです - Modal を選んで 4 つのことを解決しました:
    • 開発環境と本番環境での Python の依存関係地獄を解決します
    • コード生成の並列化
    • ローカル開発からクラウドホスト型エンドポイントへのシンプルなアップグレード経路(今後)
    • 再試行・バックオフとアタッチされたストレージを伴う耐障害性のある OpenAI API コール(今後の使用)

https://latent.space/ の購読をお願いします。より詳細な解説や洞察、考察をご覧いただけます。

注意事項

Chrome 拡張機能に取り組んでいますが、これは画像を生成する必要があるため、それらを破棄・再生成をスキップするためのユースケース固有のコードを追加しました。ただし、どのように汎化するかはまだ決めていません。

GPT-4-32k へのアクセス権がありませんが、もしあれば、API/SDK ドキュメント全体をコンテキストに入れることを探索するでしょう。

フィードバックループは現在非常に遅く(time では GPT-4 を使ったプログラム生成に 2~4 分かかり、Modal による並列化があってもそうです(時々もっと高くなります))が、それは時間とともに低下するのはほぼ確実です(下の「将来の方向性」も参照してください)。

将来の方向性

試してみるべきこと / オープンなissueディスカッションとPRを歓迎します:

  • 各生成ファイルの .md ファイルを指定します - 各ファイルの出力を微調整できるさらなるプロンプトが含まれます。
    • 基本的には popup.html.mdcontent_script.js.md などのようなものです。

— GitHub から取得した原文(一部省略の場合あり)

🐣 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)

...

examples/prompt gallery

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

  • Markdown is all you need - Markdown is the perfect way to prompt for whole program synthesis because it is easy to mix english and code (whether variable_names or entire ``` code fenced code samples)
    • turns out you can specify prompts in code in prompts and gpt4 obeys that to the letter
  • Copy and paste programming
    • teaching the program to understand how to code around a new API (Anthropic's API is after GPT3's knowledge cutoff) by just pasting in the curl input and output
    • pasting error messages into the prompt and vaguely telling the program how you'd like it handled. it kind of feels like "logbook driven programming".
  • Debugging by cating the whole codebase with your error message and getting specific fix suggestions - particularly delightful!
  • Tricks for whole program coherence - our chosen example usecase, Chrome extensions, have a lot of indirect dependencies across files. Any hallucination of cross dependencies causes the whole program to error.
    • We solved this by adding an intermediate step asking GPT to think through shared_dependencies.md, and then insisting on using that in generating each file. This basically means GPT is able to talk to itself...
    • ... but it's not perfect, yet. shared_dependencies.md is sometimes not comperehensive in understanding what are hard dependencies between files. So we just solved it by specifying a specific name in the prompt. felt dirty at first but it works, and really it's just clear unambiguous communication at the end of the day.
    • see prompt.md for SOTA smol-dev prompting
  • Low activation energy for unfamiliar APIs
    • we have never really learned css animations, but now can just say we want a "juicy css animated red and white candy stripe loading indicator" and it does the thing.
    • ditto for Chrome Extension Manifest v3 - the docs are an abject mess, but fortunately we don't have to read them now to just get a basic thing done
    • the Anthropic docs (bad bad) were missing guidance on what return signature they have. so just curl it and dump it in the prompt lol.
  • Modal is all you need - we chose Modal to solve 4 things:
    • solve python dependency hell in dev and prod
    • parallelizable code generation
    • simple upgrade path from local dev to cloud hosted endpoints (in future)
    • fault tolerant openai api calls with retries/backoff, and attached storage (for future use)

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:

  • specify .md files for each generated file, with further prompts that could finetune the output in each of them
    • so basically like popup.html.md and content_script.js.md and so on
  • b
RELATED

同じカテゴリの他のツール