Download the PHP package la-87/aipromptbuilder without Composer
On this page you can find all versions of the php package la-87/aipromptbuilder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package aipromptbuilder
AI Prompt Builder for Laravel
Introduction
The AI Prompt Builder package provides a streamlined way to interact with OpenAI's models within a Laravel application. It facilitates the construction of prompts, management of function calls, and handling of responses in a structured and configurable manner.
Installation
First, install the package via Composer:
Then, publish the configuration file:
Finally, configure the ai-prompt-builder.php
file located in your config
directory with your OpenAI API key and other settings as needed.
Configuration
The ai-prompt-builder.php
configuration file includes settings such as:
Ensure you set your OpenAI API key in your .env
file:
Usage
Basic Usage
To use the AI Prompt Builder service, you need to create an instance of the AIPromptBuilderService
and configure it with your desired settings:
Using Function Calls
You can define and use functions that the AI can call during the interaction. Implement the AIFunctionInterface
for any custom functions:
Then, register and use the function in your prompt:
Listing Available Models
You can list all available OpenAI models using the listModels
method:
Handling Function Results
To handle the results of function calls, use the askAndExecute
method followed by getFunctionResult
:
Exception Handling
The package includes custom exceptions for handling various error states:
MissingFunctionCallException
: Thrown when a function call is expected but not returned.MissingFunctionResultException
: Thrown when a function result is expected but not found.
Contributing
Contributions are welcome! Please submit a pull request or create an issue to report bugs or suggest new features.
License
This package is open-sourced software licensed under the MIT license.
All versions of aipromptbuilder with dependencies
symfony/http-client Version ^7.0
nyholm/psr7 Version ^1.8
guzzlehttp/guzzle Version ^7.8
openai-php/client Version ^0.9.0