Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Fixed non-streaming ChatCompletions.php #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/hunyuan/v20230901/ChatCompletions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use TencentCloud\Hunyuan\V20230901\HunyuanClient;
// 导入要请求接口对应的Request类
use TencentCloud\Hunyuan\V20230901\Models\ChatCompletionsRequest;
use TencentCloud\Hunyuan\V20230901\Models\Message;

use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Credential;
Expand Down Expand Up @@ -46,14 +47,18 @@ function streamProcessResult($result)
$req = new ChatCompletionsRequest();
$req->TopP = 0;
$req->Temperature = 0;
$req->Stream = false;
$req->Model = "hunyuan-standard";
$reqMessage = new Message();
$reqMessage->Role = "user";
$reqMessage->Content = "计算1+1";
$req->Messages = [$reqMessage];

// 通过client对象调用ChatCompletions方法发起请求。注意请求方法名与请求对象是对应的
$client->ChatCompletions($req);

// 返回的resp是一个ChatCompletionsResponse的实例,与请求对象对应
$resp = $client->ChatCompletions($req);
if (is_object($resp)) {
print_r($resp->toJsonString());
}

}
catch(TencentCloudSDKException $e) {
Expand Down