見出し画像

AutoGPT、BabyAGIが代表する自律型のAIエージェントが登場!

AutoGPT、BabyAGIが代表する自律型のAIエージェントが登場してからまだ4週目です。急速に拡大し、ビジネス界においてますます重要な存在となりつつあります。Webサイトの作成、SQLコードの作成、市場調査、Pythonコードの作成、そして多くの仕事を自動化できます。一方で、AI代理人によって人間の仕事が奪われるのではないかという懸念もあります。以下はその一部Twitterで話題になっている例です。これからの未来について考えてみましょう。

BabyAGIでLaravelのアプリを作ってみた(gpt-3.5-turbo)

sellPHP,ChatGPT,BabyAGI,Laravwel

概要

正確には、BabyAGIを使ってLaravelのアプリを作ってみようと思ってトライした。最初は良い感じだったけど、途中以降はループしてしまった。(同じ目的を繰り返した)でもとても可能性を感じたので、どなたかの役に立てればと思いつつ記述です。

前提条件

環境: Windows + Anaconda + Python(Python 3.9.16)
BabyAGI: https://github.com/yoheinakajima/babyagi
ChatGPT: gpt-3.5-turbo

目的

Laravelで作成した、ログイン機能付きの社員マスタを管理するWebアプリケーションを作成することを目的とした。現在知っているLaravelの最新のバージョンを言及させて、モデル、コントローラー、ビューのファイル必要な分作成ということを、最初のタスクとして与えている。

.envの設定事項

OBJECTIVEとINITIAL_TASKは、以下の通り。

OBJECTIVE=To create a web application to manage the employee master, with login functionality, made in Laravel.
INITIAL_TASK=Mention the latest version of Laravel that you currently know and create the necessary model, controller, and view files.

実行結果

以下が実行結果。なかなか動き始めは良い感じ。


@daishiro_jp
投稿日 2023年04月19日

BabyAGIでLaravelのアプリを作ってみた(gpt-3.5-turbo)

sellPHP,ChatGPT,BabyAGI,Laravwel

概要

正確には、BabyAGIを使ってLaravelのアプリを作ってみようと思ってトライした。最初は良い感じだったけど、途中以降はループしてしまった。(同じ目的を繰り返した)でもとても可能性を感じたので、どなたかの役に立てればと思いつつ記述です。

前提条件

環境: Windows + Anaconda + Python(Python 3.9.16)
BabyAGI: https://github.com/yoheinakajima/babyagi
ChatGPT: gpt-3.5-turbo

目的

Laravelで作成した、ログイン機能付きの社員マスタを管理するWebアプリケーションを作成することを目的とした。現在知っているLaravelの最新のバージョンを言及させて、モデル、コントローラー、ビューのファイル必要な分作成ということを、最初のタスクとして与えている。

.envの設定事項

OBJECTIVEとINITIAL_TASKは、以下の通り。

OBJECTIVE=To create a web application to manage the employee master, with login functionality, made in Laravel.
INITIAL_TASK=Mention the latest version of Laravel that you currently know and create the necessary model, controller, and view files.

実行結果

以下が実行結果。なかなか動き始めは良い感じ。

>python.exe .\babyagi.py

*****OBJECTIVE*****

To create a web application to manage the employee master, with login functionality, made in Laravel.

Initial task: Mention the latest version of Laravel that you currently know and create the necessary model, controller, and view files.

*****TASK LIST*****

1: Mention the latest version of Laravel that you currently know and create the necessary model, controller, and view files.

*****NEXT TASK*****

1: Mention the latest version of Laravel that you currently know and create the necessary model, controller, and view files.

*****TASK RESULT*****

The latest version of Laravel as of September 2021 is Laravel 8. 

To create the necessary model, controller, and view files for managing the employee master, you can follow these steps:

1. Create a model file for the `Employee` model using the following command:

php artisan make:model Employee


2. Create a controller file for managing the employees using the following command:

php artisan make:controller EmployeeController --resource


3. Create a view file for displaying the list of employees using the following command:

class Role extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'description',
    ];

    public function users()
    {
        return $this->belongsToMany(User::class);
    }
}


After creating the migration file and model, you can run the migration using the following command:


php artisan migrate


This will create the `roles` table in your database.
The OpenAI API rate limit has been exceeded. Waiting 10 seconds and trying again.
The OpenAI API rate limit has been exceeded. Waiting 10 seconds and trying again.

*****TASK LIST*****

1: Create a `RoleController`
2: Create an `Employee` model and migration file with columns for `name`, `email`, `password`, `remember_token`, `role_id`, `created_at`, and `updated_at`.
3: In the migration file for the `employees` table, define the columns for the `employees` table, including `name`, `email`, `password`, `remember_token`, `role_id`, `created_at`, and `updated_at`.
4:

*****NEXT TASK*****

1: Create a `RoleController`
The OpenAI API rate limit has been exceeded. Waiting 10 seconds and trying again.

*****TASK RESULT*****

Sure, here's an example `RoleController` that you can use as a starting point:


<?php

namespace App\Http\Controllers;

use App\Models\Role;
use Illuminate\Http\Request;

class RoleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $roles = Role::all();
        return view('roles.index', compact('roles'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('roles.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'name' => 'required|unique:roles|max:255',
            'description' => 'required',
        ]);

        $role = Role::create($validatedData);

        return redirect()->route('roles.index')
            ->with('success', 'Role created successfully.');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Role  $role
     * @return \Illuminate\Http\Response
     */
    public function show(Role $role)
    {
        return view('roles.show', compact('role'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Role  $role
     * @return \Illuminate\Http\Response
     */
    public function edit(Role $role)
    {
        return view('roles.edit', compact('role'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Role  $role
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Role $role)
    {
        $validatedData = $request->validate([
            'name' => 'required|max:255|unique:roles,name,'.$role->id,
            'description' => 'required',
        ]);

        $role->update($validatedData);

        return redirect()->route('roles.index')
            ->with('success', 'Role updated successfully');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Role  $role
     * @return \Illuminate\Http\Response
     */
    public function destroy(Role $role)
    {
        $role->delete();

        return redirect()->route('roles.index')
            ->with('success', 'Role deleted successfully');
    }
}


This controller provides basic CRUD functionality for the `Role` model, including listing all roles, creating a new role, editing an existing role, and deleting a role. You can customize this controller to fit your specific needs and requirements.

*****TASK LIST*****

1: Create a `Role` model with columns for `name` and `description`.
2: Create a migration file for the `roles` table, defining the columns for `name` and `description`.
3: Create a `RoleSeeder` to seed the `roles` table with default roles.
4: Create an `Employee` model and migration file with columns for `name`, `email`, `password`, `remember_token`, `role_id`, `created_at`, and `updated_at

*****NEXT TASK*****

1: Create a `Role` model with columns for `name` and `description`.

*****TASK RESULT*****

Task: Create a `Role` model with columns for `name` and `description`.

To create a `Role` model with columns for `name` and `description`, follow these steps:

1. Open your Laravel project in your preferred code editor.
2. Create a new file called `Role.php` in the `app` directory.
3. In the `Role.php` file, define the `Role` model class as follows:


<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    protected $fillable = ['name', 'description'];
}


4. In the `Role` model, we have defined the `$fillable` property to allow mass assignment of the `name` and `description` fields.
5. Save the `Role.php` file.

(中略)

見事に2時間ほど動きつづけてくれたけど、途中からは同じことを何度も繰り返してた。例えば、以下を目標の言及を何度も繰り返す結果に。上手に終了条件などを付与しなきゃいけないんだろうなぁ。

Create a Laravel migration file for the `departments` table with columns for `id`, `name`, `created_at`, and `updated_at`.

ちなみに2時間ぐるぐる動いて消費したAPI利用料は数ドル。うまく活用しない手はないよね。

考察

gpt-4だったら、またぜんぜん違うのだと思う。



この記事が気に入ったらサポートをしてみませんか?