omiya0555/laravel-prism-upstage-solar
Composer 安装命令:
composer require omiya0555/laravel-prism-upstage-solar
包简介
Laravel Prism provider for Upstage Solar models
README 文档
README
A Laravel package that provides Upstage Solar text generation models integration with Laravel Prism.
Features
- 🚀 Text Generation: Use Upstage Solar models for text generation
- 📡 Streaming: Real-time streaming responses
- ⚙️ Laravel Integration: Seamless integration with Laravel applications
- 🔧 Auto-Discovery: Automatic service provider discovery
- 📝 Configurable: Flexible configuration options
Requirements
- PHP 8.2 or higher
- Laravel 10.0, 11.0, or 12.0
- Prism PHP 0.89.0 or higher
Installation
You can install the package via composer:
composer require omiya0555/laravel-prism-upstage-solar
Publish Configuration
Publish the configuration file:
php artisan vendor:publish --tag=config --provider="Omiya0555\LaravelPrismUpstage\PrismUpstageSolarServiceProvider"
This will create a config/prism_upstage.php file in your Laravel application.
Configuration
Environment Variables
Add the following environment variables to your .env file:
# Required: Your Upstage API Key UPSTAGE_API_KEY=your_upstage_api_key_here # Optional: Custom endpoint (default shown) UPSTAGE_BASE_URL=https://api.upstage.ai/v1/solar # Optional: Default model UPSTAGE_TEXT_MODEL=solar-mini # Optional: HTTP configuration UPSTAGE_HTTP_TIMEOUT=30 UPSTAGE_HTTP_RETRY_ATTEMPTS=3 UPSTAGE_HTTP_RETRY_DELAY=1000
Getting Your API Key
- Sign up at Upstage Console
- Create a new API key
- Add the API key to your
.envfile
Usage
Basic Text Generation
use Prism\Prism\Prism; $response = Prism::text() ->using('upstage', 'solar-mini') ->withPrompt('Explain quantum computing in simple terms.') ->asText(); echo $response->text;
With System Prompt
$response = Prism::text() ->using('upstage', 'solar-mini') ->withSystemPrompt('You are a helpful assistant that responds in Japanese.') ->withPrompt('量子コンピュータについて簡単に説明してください。') ->asText(); echo $response->text;
Advanced Configuration
$response = Prism::text() ->using('upstage', 'solar-mini') ->withPrompt('Write a creative story about AI.') ->withMaxTokens(500) ->withTemperature(0.7) ->withTopP(0.9) ->asText(); echo $response->text; echo "Tokens used: " . $response->usage->totalTokens();
Streaming Responses
$stream = Prism::text() ->using('upstage', 'solar-mini') ->withPrompt('Tell me a story about space exploration.') ->asStream(); foreach ($stream as $chunk) { echo $chunk->text; flush(); // Send output to browser immediately }
Available Models
Text Generation Models
solar-mini: Fast and efficient model for general taskssolar-1-mini: Improved version with better performancesolar-pro: Advanced model for complex tasks
Laravel Integration Examples
Controller Example
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Prism\Prism\Prism; class ChatController extends Controller { public function chat(Request $request) { $request->validate([ 'message' => 'required|string|max:1000', ]); try { $response = Prism::text() ->using('upstage', config('prism_upstage.default_model')) ->withPrompt($request->input('message')) ->asText(); return response()->json([ 'response' => $response->text, 'usage' => [ 'prompt_tokens' => $response->usage->promptTokens, 'completion_tokens' => $response->usage->completionTokens, ], ]); } catch (\Exception $e) { return response()->json([ 'error' => 'Failed to generate response', 'message' => $e->getMessage(), ], 500); } } }
Artisan Command Example
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Prism\Prism\Prism; class GenerateText extends Command { protected $signature = 'upstage:generate {prompt}'; protected $description = 'Generate text using Upstage Solar model'; public function handle() { $prompt = $this->argument('prompt'); try { $response = Prism::text() ->using('upstage', config('prism_upstage.default_model')) ->withPrompt($prompt) ->asText(); $this->info('Generated text:'); $this->line($response->text); $this->info('Tokens used: ' . $response->usage->totalTokens()); } catch (\Exception $e) { $this->error('Failed to generate text: ' . $e->getMessage()); return 1; } return 0; } }
Error Handling
The package includes comprehensive error handling:
use Prism\Prism\Exceptions\PrismException; use Prism\Prism\Exceptions\PrismRateLimitedException; use Prism\Prism\Exceptions\PrismRequestTooLargeException; try { $response = Prism::text() ->using('upstage', 'solar-mini') ->withPrompt('Your prompt here') ->asText(); } catch (PrismRateLimitedException $e) { // Handle rate limiting logger()->warning('Rate limit exceeded', ['exception' => $e]); } catch (PrismRequestTooLargeException $e) { // Handle request too large logger()->error('Request too large', ['exception' => $e]); } catch (PrismException $e) { // Handle general Prism exceptions logger()->error('Prism error', ['exception' => $e]); } catch (\Exception $e) { // Handle any other exceptions logger()->error('Unexpected error', ['exception' => $e]); }
Testing
composer test
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.
omiya0555/laravel-prism-upstage-solar 适用场景与选型建议
omiya0555/laravel-prism-upstage-solar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「solar」 「prism」 「ai」 「llm」 「upstage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 omiya0555/laravel-prism-upstage-solar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 omiya0555/laravel-prism-upstage-solar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 omiya0555/laravel-prism-upstage-solar 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK for shopex prism platform
Adds a new field type that provides syntax highlighting capabilities using PrismJS.
Production-ready AI workflows for Laravel — resilient calls with retries, fallback models, and prompt management.
微信小程序生成太阳码
Solar icon pack for Filament Icons
Iranian Date for Contao
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-15