Download the PHP package swapinvidya/laravel-huggingface-client without Composer
On this page you can find all versions of the php package swapinvidya/laravel-huggingface-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download swapinvidya/laravel-huggingface-client
More information about swapinvidya/laravel-huggingface-client
Files in swapinvidya/laravel-huggingface-client
Package laravel-huggingface-client
Short Description A Laravel package for interacting with Hugging Face API
License MIT
Informations about the package laravel-huggingface-client
Laravel Hugging Face Client
swapinvidya/laravel-huggingface-client is a Laravel package that simplifies integration with the Hugging Face API. This package provides an easy way to interact with models for text generation, image creation, and other AI-powered features.
Features
- Text Generation: Generate text using models like
gpt2
andgpt-neo
. - Image Generation: Create images based on text prompts using models such as
stable-diffusion
. - Custom Model Completions: Use any available Hugging Face model for specialized tasks.
- Seamless Integration: Built for Laravel, with easy dependency injection.
Installation
Step 1: Install via Composer
Run the following command in your Laravel project directory:
Step 2: Publish Configuration
Publish the configuration file to customize your API key and other options:
Step 3: Set Up API Key
Add your Hugging Face API key to the .env
file:
Configuration
The configuration file will be published to config/huggingface.php
. You can customize your API key and other settings there.
Usage
Inject the HuggingFaceClient
in your controllers or services to use its capabilities.
Example: Generate Text
Example: Generate Image
Example: Custom Model Completion
Available Methods
generateText($model, $input)
Generates text output using the specified model.
$model
: The model to use (e.g.,gpt2
,gpt-neo
).$input
: The text input/prompt for the model.
generateImage($model, $input)
Creates an image based on a text prompt.
$model
: The image generation model (e.g.,stable-diffusion
).$input
: The text prompt describing the image.
generateCompletion($model, $params)
Generates a completion response with custom parameters.
$model
: The model to use (e.g.,gpt-neo
,opt
).$params
: Array of parameters includinginputs
and optional model settings liketemperature
andmax_new_tokens
.
Error Handling
The client will return error information in the response if a request fails:
Testing
To test your package locally, you can link it to a Laravel project using:
Contributing
Feel free to open issues or submit pull requests for improvements and new features.
License
This package is open-source software licensed under the MIT license.
Developed by swapinvidya
All versions of laravel-huggingface-client with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0