dog729 / laravel-sklearnbot
laravel sklern bot
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/dog729/laravel-sklearnbot
Requires
- php: >=8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- laravel/framework: >=7.0
This package is auto-updated.
Last update: 2025-10-12 03:45:01 UTC
README
LaravelSklearnBot is a Laravel package that allows you to parse data, create and train models, and use them to generate responses to requests.
Installation
- Install the required dependencies:
pip install flask scikit-learn python-dotenv
- Add LaravelSklearnBotto yourcomposer.jsonand run the following command:
composer require dog729/laravel-sklearnbot
Usage
Example Method Calls
To use the package, invoke the following methods from the SklearnbotFacade:
- 
Parse data with training: \LaravelSklearnBot\SklearnbotFacade::parserHelpBotModel(); 
- 
Retrain the model from scratch: \LaravelSklearnBot\SklearnbotFacade::trainModelFromScratch(); 
- 
Get a response from the model based on a query: $result = \LaravelSklearnBot\SklearnbotFacade::getHelpBotResponse('hi'); print_r($result); 
- 
Fine-tune the model: \LaravelSklearnBot\SklearnbotFacade::fineTuneModelHelpBot([ [ 'id' => 8, 'type' => 'sw', 'title' => 'Darth Vader', 'text' => 'Anakin pam pam', ] ]); $result = \LaravelSklearnBot\SklearnbotFacade::getHelpBotResponse('Darth Vader'); print_r($result); // Returns: Array ( [action] => Array ( ) [id] => 8 [text] => Anakin pam pam [type] => sw ) 
Console Commands
- 
Create a helpbot model handler file: php artisan make:helpbotmodel {name}
- 
Install the package and generate necessary files: php artisan helpbot:installThis command will install the package, generate a token, and create the helpbot.pyfile.
Configuration
The configuration file config/sklearnbot.php contains the following parameters:
return [ /** * Logic for the operation of submodules */ 'helpbot' => 'python', 'python' => [ 'run' => 'app.py', /** * host:port for the running Flask application */ 'helpbot_token' => ENV('HELPBOT_TOKEN'), 'helpbot_host' => ENV('HELPBOT_FLASK_HOST',"127.0.0.1"), 'helpbot_port' => ENV('HELPBOT_FLASK_PORT',"5729"), /** * The name of the model files */ 'helpbot_model' => 'helpbot', 'helpbot_model_addtraining' => true, //auto further training of the model 'helpbot_pkl' => ENV('HELPBOT_PKL','model.pkl'), //model helpbot 'helpbot_output_pkl' => ENV('HELPBOT_OUTPUT_PKL','output.pkl'), //model helpbot database ], ];
Running and Testing
Examples for testing with curl:
- 
Create a model: curl -X POST http://127.0.0.1:5729/create-model -H "Content-Type: application/json" -H "Authorization: your-secure-token"
- 
Reload the model: curl -X POST http://127.0.0.1:5729/reload-model -H "Content-Type: application/json" -H "Authorization: your-secure-token"
- 
Fine-tune the model: curl -X POST http://127.0.0.1:5729/fine-tune-model -H "Content-Type: application/json" -H "Authorization: your-secure-token" -d '[{"id":"3","title":"boba","text":"aboba"}]'
- 
Get a response: curl -X POST http://127.0.0.1:5729/get-response -H "Content-Type: application/json" -d '{"text":"boba"}'