codingwisely/taskallama
Composer 安装命令:
composer require codingwisely/taskallama
包简介
Taskallama is a Laravel package that seamlessly integrates with Ollama’s LLM API to empower your applications with AI-driven text generation, task management assistance, and more. Designed for simplicity and scalability, Taskallama brings the power of language models to your Laravel projects.
README 文档
README
Taskallama is a Laravel package that provides seamless integration with Ollama's LLM API. It simplifies generating AI-powered content, from professional task writing to conversational agents, with minimal effort. Whether you're building a task management system, an HR assistant for job posts, or blog content generation, Taskallama has you covered.
Why i built it? Simple reasons - i want to implement a ai helper on or Project and task management system at Taskavel.com to help me quickly scaffold the task. We gonna use it also on our another SaaS project, Advanced ATS system at Bagel.blue to make it easy to create a Job Postings.
Features
- Simple API for generating AI responses via the Ollama LLM.
- Supports task creation, conversational AI, embeddings, and more.
- Customizable agent personalities for tailored responses.
- Integration with Laravel Livewire for real-time interactions.
- Configurable options like streaming, model selection, and temperature.
Prerequisites
-
Ollama Installation
- Taskallama requires Ollama to be installed and running locally on your machine. You can download and install Ollama from their official website:
-
Ollama Configuration
- By default, Taskallama connects to Ollama at
http://127.0.0.1:11434. Ensure that Ollama is running and accessible at this address. You can update theOLLAMA_URLin the config file if it's hosted elsewhere.
- By default, Taskallama connects to Ollama at
-
System Requirements
- PHP
^8.3or higher. - Laravel
^11.0or higher.
- PHP
Installation
You can install the package via composer:
composer require codingwisely/taskallama
Next, you should publish the package's configuration file:
php artisan vendor:publish --tag="taskallama-config"
This will publish a taskallama.php file in your config directory where you can configure your Ollama API key and other settings.
return [ 'model' => env('OLLAMA_MODEL', 'llama3.2'), 'default_format' => 'json', 'url' => env('OLLAMA_URL', 'http://127.0.0.1:11434'), 'default_prompt' => env('OLLAMA_DEFAULT_PROMPT', 'Hello Taskavelian, how can I assist you today?'), 'connection' => [ 'timeout' => env('OLLAMA_CONNECTION_TIMEOUT', 300), ], ];
Usage
Basic Example (non-stream)
Generate a response using a prompt:
use CodingWisely\Taskallama\Facades\Taskallama; $response = Taskallama::agent('You are a professional task creator...') ->prompt('Write a task for implementing a new feature in a SaaS app.') ->model('llama3.2') ->options(['temperature' => 0.5]) ->stream(false) ->ask(); return $response['response'];
Basic Example (stream)
Generate a stream response using a prompt:
use CodingWisely\Taskallama\Facades\Taskallama; return response()->stream(function () use () { Taskallama::agent('You are a professional task creator...') ->prompt('Write a task for implementing a new feature in a SaaS app.') ->model('llama3.2') ->options(['temperature' => 0.5]) ->stream(true) ->ask(); }, 200, [ 'Cache-Control' => 'no-cache', 'X-Accel-Buffering' => 'no', 'Content-Type' => 'text/event-stream', ]);
Chat Example
Create a conversational agent:
use CodingWisely\Taskallama\Facades\Taskallama; $messages = [ ['role' => 'user', 'content' => 'Tell me about Laravel'], ['role' => 'assistant', 'content' => 'Laravel is a PHP framework for web development.'], ['role' => 'user', 'content' => 'Why is it so popular?'], ]; $response = Taskallama::agent('You are a Laravel expert.') ->model('llama3.2') ->options(['temperature' => 0.7]) ->chat($messages);
Livewire Integration Example
Integrate Taskallama into a Livewire component for real-time task generation:
namespace App\Livewire; use CodingWisely\Taskallama\Taskallama; use Livewire\Component; class AskTaskallama extends Component { public $question = ''; public $response = ''; public function ask() { if (empty(trim($this->question))) { $this->response = "Please provide a valid question."; return; } try { $this->response = Taskallama::agent('You are a task-writing assistant.') ->prompt($this->question) ->model('llama3.2') ->options(['temperature' => 0]) ->stream(false) ->ask()['response'] ?? "No response received."; } catch (\Exception $e) { $this->response = "Error: " . $e->getMessage(); } } public function render() { return view('livewire.ask-taskallama'); } }
Embeddings Example
Generate embeddings for advanced search or semantic analysis:
$embeddings = Taskallama::agent('Embedding Assistant') ->model('llama3.2') ->options(['temperature' => 0.5]) ->ask(); print_r($embeddings);
Additional Methods
List Local Models
$models = Taskallama::getInstance()->listLocalModels(); print_r($models);
Retrieve Model Information
$modelInfo = Taskallama::getInstance()->getModelInfo('llama3.2'); print_r($modelInfo);
Retrieve Model Settings
$modelSettings = Taskallama::getInstance()->getModelSettings('llama3.2'); print_r($modelSettings);
Pull or Delete a Model
If you're pulling model, make sure you set this a background job, as it may take a while to download the model.
$pullModel = Taskallama::getInstance()->pull('mistral'); $deleteModel = Taskallama::getInstance()->delete('mistral');
Testing
Run the tests with:
composer test
License
This package is open-source software licensed under the MIT License. Please see the LICENSE.md file for more information.
codingwisely/taskallama 适用场景与选型建议
codingwisely/taskallama 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 130 次下载、GitHub Stars 达 11, 最近一次更新时间为 2024 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「CodingWisely」 「taskallama」 「Ollama LLM」 「larevel ai」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codingwisely/taskallama 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codingwisely/taskallama 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codingwisely/taskallama 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Auto generating unique slugs for your Laravel model
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
统计信息
- 总下载量: 130
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-17