jiannei/laravel-spark-ai

Spark ai adapter for laravel.

v1.0.0 2024-01-11 07:37 UTC

This package is auto-updated.

Last update: 2024-10-11 09:36:58 UTC


README

讯飞星火大模型非官方 SDK.

StyleCI Latest Stable Version Total Downloads Latest Unstable Version License

介绍

安装

$ composer require jiannei/laravel-spark-ai -vvv

配置

控制台获取服务接口认证信息:APPID、APISecret、APIKey

config/services.php 中添加配置参数

// config/services.php
<?php

return [
    // ...
    'xfyun' => [
        // 密钥信息,在开放平台-控制台中获取:https://console.xfyun.cn/services/cbm
        'url' => env('XFYUN_URL'),
        'app_id' => env('XFYUN_APP_ID'),
        'api_key' => env('XFYUN_API_KEY'),
        'api_secret' => env('XFYUN_API_SECRET'),
    ],
];

.env中填入前面获取的参数信息

XFYUN_URL=
XFYUN_APP_ID=
XFYUN_API_KEY=
XFYUN_API_SECRET=

使用

  • 流式输出
use Jiannei\LaravelSparkAi\Support\Facades\SparkAi;


$answer = SparkAi::chat()->create('你是谁?');

foreach ($answer as $item) {
    print_r($item);
}

answer

  • 完整输出
use Jiannei\LaravelSparkAi\Support\Facades\SparkAi;


$answer = SparkAi::chat()->answer('你是谁?');

print_r($answer);

License

MIT