DEV Community

Cover image for πŸ•΅ What You Didn't Know About AI Integration for Laravel Applications
Andrii
Andrii

Posted on

πŸ•΅ What You Didn't Know About AI Integration for Laravel Applications

🚨 Great news for Laravel developers!

We're working on a package called GptSdk that allows you to build AI features in Laravel applications in minutes.

What we know about AI features? In general, it should be a prompt and something that transforms prompt output into user-friendly results. That's all. But for every successful project, there are huge backend tasks: continuous updates of business logic, new requirements, and adapting to new market trends. Hard-coded prompts can quickly become a pain. πŸ’©

If you've encountered this problem or have decided to embark on your AI journey, consider trying the GptSdk package, available at https://github.com/growthapps/gptsdk.

All you need to add AI features to your app today is to:

  • Install the library.
  • Create a free GptSdk account at https://gpt-sdk.com.
  • Define your prompt.
  • Add a small snippet to your codebase:
$gptSdkClient = new GptSdkApiClient(
    HttpClient::create(),
    '<your api key here>'
);
$promptRun = $gptSdkClient->runPrompt(
    new PromptRun(
        vendorKey: VendorEnum::OPENAI,
        promptMessages: new ArrayCollection(
            [
                new PromptMessage(
                    role: 'User',
                    content: 'Hello gpt! How are you? Reply in [[tone]] tone.'
                )
            ]
        ),
        promptKey: 'hello_prompt',
        params: new ArrayCollection(
            [
                new PromptParam(
                    type: Type::STRING,
                    key: 'tone',
                    value: 'angry'
                )
            ]
        ),
    )
);
Enter fullscreen mode Exit fullscreen mode

That's all! The next step is to enjoy AI integration and move forward in building great applications. πŸ¦„

Top comments (0)