定制 tenko/ai-tools-php 二次开发

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

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

tenko/ai-tools-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tenko/ai-tools-php

包简介

Ai Utils for ChatGPT and Azure

README 文档

README

This is a Util for ChatGPT and Azure.

Quick Start

Install

composer require tenko/ai-tools-php

Usage

  • ChatGPT:
<?php

$config = new OpenAiConfig();
$config->setApiKeys([
    'key1',
    'key2',
    // more...
]);

// proxy if you need, "https://api.openai.com" will be replaced by "https://example.com/" in request url.
$config->setAgencyUrl('https://example.com/');

$service = new OpenAI($this->getOpenAiConfig());

$service->setContext(
    new GptContext(GptRoleEnum::SYSTEM, '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本'),
    new GptContext(GptRoleEnum::USER, '你好')
);
// or
$service->setContext(...GptContext::construct([
    [
        'role' => 'system',
        'content' => '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本'
    ],
    [
        'role' => 'user',
        'content' => '你好'
    ]
]));

$response = $service->chat();

var_dump($response);

echo $response->getResponse();
  • Azure:
$config = new AzureConfig();
$config->setApiVersion('');
$config->setDeployments('');
$config->setResourceName('');
$config->setApiKeys([
    'key1',
    'key2',
    // more...
]);

$service = new Azure($this->getAzureConfig());
$service->setContext(
    new GptContext(GptRoleEnum::SYSTEM, '现在你将模仿一只猫娘,与我对话每一句话后面都要加上“喵”,我是你的主人。简短回复,不要回复长文本'),
    new GptContext(GptRoleEnum::USER, '你好')
);

$response = $service->chat();

var_dump($response);

echo $response->getResponse();

For more details, see configs.md

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-26