Commit ea8bb346 authored by 刘小敏's avatar 刘小敏

AI试戴 接口增加日志

parent f40b76ad
......@@ -11,7 +11,7 @@ class Ai
{
// 火山引擎方舟配置
private $ark_host = 'https://ark.cn-beijing.volces.com';
private $api_key = ''; // 我的个人Key
private $api_key = ''; // AI接口key
public function __construct(){
$this->api_key = config('shopro.ai_api_key');
......@@ -48,6 +48,9 @@ class Ai
'verify' => false, // 关闭 SSL 证书验证
'allow_redirects' => true
];
// 记录入参日志
Log::info('用户ID:'. $userId . ' response_format'. $response_format . ' AI生成图片接口入参:'.json_encode($params));
// 发送请求
$client = new Http();
$response = $client->post($url, $params);
......@@ -57,8 +60,8 @@ class Ai
$content = preg_replace('/[^\x20-\x7E]/', '', $content);
$result = json_decode($content, true);
// 记录日志
Log::info('用户ID:'. $userId .' AI生成图片接口返回:'.json_encode($result));
// 记录出参日志
Log::info('用户ID:'. $userId . ' response_format'. $response_format .' AI生成图片接口返回:'.json_encode($result));
if ($response_format == 'b64_json'){
if (!$result || !isset($result['data'][0]['b64_json'])) {
......@@ -93,7 +96,7 @@ class Ai
];
} catch (\Exception $e) {
Log::error('用户ID:'. $userId .' AI生成图片异常:' . $e->getMessage());
Log::error('用户ID:'. $userId . ' response_format'. $response_format .' AI生成图片异常:' . $e->getMessage());
return [
'code' => 0 ,
'msg' => '请求异常:' . $e->getMessage()
......@@ -146,6 +149,10 @@ class Ai
'verify' => false, // 关闭 SSL 证书验证
'allow_redirects' => true
];
// 记录入参日志
Log::info('用户ID:'. $userId .' AI生成视频接口入参:'.json_encode($params));
// 发送请求
$client = new Http();
$response = $client->post($url, $params);
......@@ -155,8 +162,9 @@ class Ai
$content = preg_replace('/[^\x20-\x7E]/', '', $content);
$result = json_decode($content, true);
// 记录日志
// 记录出参日志
Log::info('用户ID:'. $userId .' AI生成视频接口返回:'.json_encode($result));
return [
'code' => 1 ,
'msg' => '视频生成中' ,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment