Ask AI Questions About Your Codebase from the CLI With Laragenie

Laragenie is an AI chatbot with an Artisan console integration for your Laravel applications. It can understand your source code by indexing directory/file paths. You can then ask questions about your code such as "Describe all the model associations for the App\Models\Post model".

Here's an example of how you can configure the indexes in your configuration file. It works by indexing your configured files with an AI model using OpenAI to generate responses and Pinecone to index data:

// config/laragenie.php
return [
    // ...
    'indexes' => [
        'directories' => ['App/Models', 'App/Http/Controllers'],
        'files' => ['tests/Feature/MyTest.php'],
        'removal' => [
            'strict' => true,
        ],
    ],
];

Once you’ve installed this package, you can index your files, clear the index, and ask questions by running the laragenie command:

The Laragenie AI prompt
Ask questions about your code from the command line.

Note that the files you index and ask questions about needn’t be only PHP files! You can also index and ask questions about your JavaScript, GitHub workflows, etc. The neat thing about this CLI is that it’s not generic answers; it’s specifically helpful to answer questions about your unique codebases.

Using AI models is a valuable way to speed up tedious tasks. It can be helpful in onboarding developers new to a project and getting general knowledge about an unfamiliar codebase more rapidly.

This package is available on Github at joshembling/laragenie and installable via composer:

composer require --dev joshembling/laragenie

The post Ask AI Questions About Your Codebase from the CLI With Laragenie appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.