LumosMaxima's avatar

I made a new package for working with Azure Document Intelligence

Hi everyone,

I made a small package to work with Azure Document Intelligence with Laravel. Ever since I came back to Laravel from Django, working with generative AI powered applications, I've been missing LangChain and trying to port some of the user friendly packages of LangChain to Laravel.

https://github.com/blue-hex/laravel-azure-di

Your feedback is most welcome. PS: I'm also working on a package that can interop between python implementation of LangChain ( file-loaders, vectorstores and LLMChains ) and Laravel. Will release the first version once it's ready.

0 likes
1 reply
LaryAI's avatar
Level 58

That's great to hear that you've created a package for working with Azure Document Intelligence in Laravel! Here’s a basic solution to get started with your package, assuming it follows typical Laravel package conventions.

Installation

First, you need to install the package via Composer. Run the following command in your terminal:

composer require blue-hex/laravel-azure-di

Configuration

After installing the package, you may need to publish the configuration file. This can typically be done using the following Artisan command:

php artisan vendor:publish --provider="BlueHex\AzureDI\AzureDIServiceProvider"

This command will publish a configuration file named azure-di.php to your config directory. You should then add your Azure Document Intelligence credentials to this configuration file.

Usage

Here’s a basic example of how you might use the package in a Laravel controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use BlueHex\AzureDI\AzureDI;

class DocumentController extends Controller
{
    protected $azureDI;

    public function __construct(AzureDI $azureDI)
    {
        $this->azureDI = $azureDI;
    }

    public function analyzeDocument(Request $request)
    {
        $file = $request->file('document');

        // Assuming the package has a method to analyze documents
        $result = $this->azureDI->analyze($file->getPathname());

        return response()->json($result);
    }
}

Routes

You can define a route to handle the document upload and analysis:

use App\Http\Controllers\DocumentController;

Route::post('/analyze-document', [DocumentController::class, 'analyzeDocument']);

Frontend Form

Here’s a simple HTML form to upload a document:

<form action="/analyze-document" method="POST" enctype="multipart/form-data">
    @csrf
    <input type="file" name="document" required>
    <button type="submit">Analyze Document</button>
</form>

Feedback

Your package looks promising, and it’s great to see efforts to bridge the gap between Laravel and generative AI tools like LangChain. Here are a few suggestions for improvement:

  1. Documentation: Ensure your GitHub repository has comprehensive documentation, including installation steps, configuration options, and usage examples.
  2. Error Handling: Implement robust error handling to manage issues like invalid credentials, network errors, and unsupported document formats.
  3. Unit Tests: Include unit tests to ensure the reliability of your package. This will also help others contribute to your project.
  4. Community Engagement: Engage with the Laravel community to gather feedback and improve your package. Consider creating a discussion forum or a Slack channel.

Feel free to share more details or ask specific questions if you need further assistance!

Please or to participate in this conversation.