定制 wolfcode/php-ai 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wolfcode/php-ai

最新稳定版本:v0.1.3

Composer 安装命令:

composer require wolfcode/php-ai

包简介

php-ai

README 文档

README

Require

  • PHP 8.1+
  • GuzzleHttp 7.9.0+

Installation

composer require wolfcode/php-ai

Demo

<?php

namespace App\Demo;

use Wolfcode\Ai\Enum\AiType;
use Wolfcode\Ai\Service\AiChatService;

class Demo{

    public function test()
    {
    
      $single = AiChatService::instance();
      $result = $single
            // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0
            // ->setTimeLimit(0)
            // 请替换为您需要的模型类型
            ->setAiType(AiType::QWEN)
            // 如果需要指定模型的 API 地址,可自行设置
            // ->setAiUrl('https://xxx.com')
            // 请替换为您的模型
            ->setAiModel('qwen-plus')
            // 请替换为您的 API KEY
            ->setAiKey('sk-1234567890')
            // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用
            ->setSystemContent('你现在是一位资深的海外电商产品经理')
            ->chat('who are you ?');
            
        $result2 = $single
            // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0
            // ->setTimeLimit(0)
            // 请替换为您需要的模型类型
            ->setAiType(AiType::DOUBAO)
            // 如果需要指定模型的 API 地址,可自行设置
            // ->setAiUrl('https://xxx.com')
            // 请替换为您的模型
            ->setAiModel('doubao-1-5-pro-32k-250115')
            // 请替换为您的 API KEY
            ->setAiKey('sk-1234567890')
            // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用
            ->setSystemContent('你现在是一位资深的海外电商产品经理')
            ->chat('who are you ?');    
            
        $result3 = $single
            // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0
            ->setTimeLimit(0)
            // 请替换为您需要的模型类型
            ->setAiType(AiType::DEEPSEEK)
            // 如果需要指定模型的 API 地址,可自行设置
            // ->setAiUrl('https://xxx.com')
            // 请替换为您的模型
            ->setAiModel('deepseek-reasoner')
            // 请替换为您的 API KEY
            ->setAiKey('sk-1234567890')
            // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用
            ->setSystemContent('你现在是一位资深的海外电商产品经理')
            ->chat('who are you ?'); 
            
        // 当 AiType 不在枚举范围内时,可自行设置
        $resultCustom = $single->customChat([
                'url'      => 'https://api.siliconflow.cn/v1/chat/completions',
                'key'      => 'sk-1234567890',
                'model'    => 'deepseek-ai/DeepSeek-R1',
                'messages' => [
                    ['role' => 'system', 'content' => '你是一个AI助手'],
                    ['role' => 'user', 'content' => '高斯的主要成就有哪些?'],
                ]
            ]
        );
            
    }
}

统计信息

  • 总下载量: 2.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-03-07