Download the PHP package creativecrafts/laravel-ai-assistant without Composer
On this page you can find all versions of the php package creativecrafts/laravel-ai-assistant. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download creativecrafts/laravel-ai-assistant
More information about creativecrafts/laravel-ai-assistant
Files in creativecrafts/laravel-ai-assistant
Package laravel-ai-assistant
Short Description A handy package to access and interact with OpenAi endpoint
License MIT
Homepage https://github.com/creativecrafts/laravel-ai-assistant
Informations about the package laravel-ai-assistant
A handy package to access and interact with Openai end point
The Laravel AI Assistant package provides an easy-to-use interface for interacting with OpenAI’s API using Laravel. This package allows developers to create, manage, and interact with AI assistants, including handling tasks like text completions, code interpretation, function calling, and more. It abstracts the complexity of interacting directly with OpenAI’s API by providing structured methods for configuring and using AI assistants in your Laravel applications.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
Configuration
The ai-assistant.php
configuration file now includes a new chat_model
option.
Newly Added Features
• Create and manage AI assistants.
• Set models, temperature, and custom instructions for the assistant.
• Utilize tools like code interpretation, file search, and custom function calls.
• Interact with assistants via threads for tasks like message completion, chat, and task processing.
• Supports both synchronous and streamed completions.
• Handle audio transcription and translation with OpenAI models.
Usage
-
Creating and Configuring an AI Assistant
- Including Tools
You can include various tools to enhance the functionality of the assistant. For example, if you want the assistant to use the code interpreter, you can include it like this:
- Interacting with the Assistant
Available Methods
init(): Assistant: Initializes the AI assistant.
• setModelName(string $modelName): Assistant: Sets the model name for the AI assistant.
• adjustTemperature(int|float $temperature): Assistant: Adjusts the assistant’s response temperature.
• setAssistantName(string $assistantName): Assistant: Sets the name for the assistant.
• setAssistantDescription(string $assistantDescription): Assistant: Sets the assistant’s description.
• setInstructions(string $instructions): Assistant: Sets instructions for the assistant.
• includeCodeInterpreterTool(array $fileIds = []): Assistant: Adds the code interpreter tool to the assistant.
• includeFileSearchTool(array $vectorStoreIds = []): Assistant: Adds the file search tool to the assistant.
• includeFunctionCallTool(...): Assistant: Adds a function call tool to the assistant.
• create(): NewAssistantResponseData: Creates the assistant using the specified configurations.
• assignAssistant(string $assistantId): Assistant: Assigns an existing assistant by ID.
• createTask(array $parameters = []): Assistant: Creates a new task thread for interactions.
• askQuestion(string $message): Assistant: Asks a question in the task thread.
• process(): Assistant: Processes the task thread.
• response(): string: Retrieves the assistant’s response.
Exception Handling
The package includes several custom exceptions to handle errors gracefully:
• CreateNewAssistantException: Thrown when the creation of a new assistant fails.
• MissingRequiredParameterException: Thrown when a required parameter is missing in a message or task.
Upcoming features
• Create and upload files for code interpretation, then assign it to a specific assistant.
• Create and upload vector store, then attach the vector store ids to an assistant.
• Get a list of all created assistant.
• Get a list of all created files.
• Get a list of all created vector stores.
• Update assistant.
• Delete assistant.
If you have any feature requests or suggestions, please feel free to open an issue or submit a pull request.
Compatibility
This fork is compatible with OpenAI API as of August 2024. It uses the gpt-3.5-turbo model by default, but you can specify gpt-4 or other available models in your configuration if you have access to them.
Add to .env
Testing
The package now has 100% code and mutation test coverage. You can run the tests using the following command:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Godspower Oduose
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-ai-assistant with dependencies
guzzlehttp/guzzle Version ^7.8
illuminate/contracts Version ^11.0|^10.0
openai-php/client Version ^0.7|^0.8
spatie/laravel-package-tools Version ^1.16
symfony/http-client Version ^6.3|^7.0