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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ai-assistant

Laravel AI Assistant

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel AI Assistant is a comprehensive package designed to seamlessly integrate OpenAI’s powerful language models into your Laravel applications. It provides an easy-to-use, fluent API to configure, manage, and interact with AI-driven chatbots, audio transcription services, custom function calls, and additional advanced tools.


Table of Contents


Overview

Laravel AI Assistant simplifies the integration of AI models into your Laravel application. Whether you’re building a conversational chatbot, automating content creation, or transcribing audio files, this package provides a clean, expressive API to handle complex tasks with minimal effort.

It leverages OpenAI’s API to:


Features


Installation

You can install the package via composer:

You can publish the config file with:

Configuration

After publishing, you will find a configuration file at config/ai-assistant.php. This file includes settings for:

API Credentials

Set your OpenAI API key and organization:

Model Settings

Choose your default models for chat, editing, and audio transcription:

Response Settings

Configure parameters such as temperature, top_p, max tokens, streaming options, stop sequences, etc.:

Roles

Define the roles for AI responses and user messages:

Usage

Initializing the Assistant

Create a new assistant instance using the fluent API:

Configuring Chat and Task Settings

Configure the model, temperature, and other parameters:

Send your chat message and retrieve a response:

You can also manage caching of chat messages, adjust the maximum number of tokens, or define stop sequences using dedicated methods.

Audio Transcription

Transcribe audio files by setting the file path and specifying language and an optional prompt:

Tool Integrations

Integrate additional tools like custom function calls, code interpreter, or file search:

Data Transfer Objects (DTOs) and Factories

The package includes several DTOs and factory classes to structure data consistently: • CreateAssistantData: Used when creating a new assistant. • ChatCompletionData: Represents data for chat completions. • ChatAssistantMessageData: Structures assistant messages. • TranscribeToData: Structures data for audio transcription requests. • CustomFunctionData: Represents custom function tool data.

Each DTO includes a toArray() method to facilitate easy conversion and integration with the API.

This is the contents of the published config file:

Configuration File

The config/ai-assistant.php file allows you to customize settings such as API credentials, model names, temperature, top_p, and more. Adjust these settings to fit your use case:

Error Handling

The package provides robust error handling: • File Operations: Methods like openFile() throw a RuntimeException if the file cannot be opened. • API Interactions: The create() method catches exceptions from OpenAI and rethrows them as a CreateNewAssistantException with a descriptive message. • Validation: Methods that require specific parameters (e.g., audio voice and format for audio output) throw an InvalidArgumentException when expectations are not met.

Examples

Example: Simple Chat Interaction

Example: Audio Transcription

Example: Custom Function Call

Example: Creating and Configuring an AI Assistant

Example: Interacting with the Assistant

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.

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.
. setAssistantId(string $assistantId): Assistant: Sets the assistant ID for the current interaction.    

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

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-ai-assistant with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.2
guzzlehttp/guzzle Version ^7.9
illuminate/contracts Version ^12.0|^11.0|^10.0
openai-php/client Version ^0.7|^0.10
spatie/laravel-package-tools Version ^1.19
symfony/http-client Version ^6.3|^7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package creativecrafts/laravel-ai-assistant contains the following files

Loading the files please wait ....