Giter Club home page Giter Club logo

cmer-llm-chat's Introduction

Cmer LLm Chat PHP SDK

创贸集团的LLM聊天服务PHP SDK
负责发起聊天请求。
请求参数参考文档地址:https://apihub.cmer.com/docs/llm-chat.html

安装

composer require hbb/cmer-llm-chat

使用

<?php

require_once "vendor/autoload.php";

$apikey="xxxxxxxxxx";
$client = new \Hbb\CmerLlmChat\CmerClient($apikey);
# 修改超时时间,默认60秒
$client->timeout=300;
# 组装请求体参数
$messages = [
    ['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"],
    ['role' => 'user', 'content' => '创贸集团有多少技术?'],
    ['role' => 'assistant', 'content' => '创贸集团有200+技术。'],
    ['role' => 'user', 'content' => '今天天气怎么样']
];
$payload = new \Hbb\CmerLlmChat\models\ChatModel($messages);
# 修改模型名称,豆包,Gpt,Claude
# todo 更多参数请查看 \Hbb\CmerLlmChat\CmerClient 类
$payload->model = "gpt-3.5-turbo-0125";
$payload->supplier = "azure";
# 发送请求
$response = $client->chat($payload);
print_r($response->getBody()->getContents());

# 发送流式请求
$payload->stream = true;
$response = $client->chat($payload);
$body = $response->getBody();
while (!$body->eof()) {
    echo $body->read(1024);
}

cmer-llm-chat's People

Contributors

haizibinbin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.