Initial commit: queue workspace
Made-with: Cursor
This commit is contained in:
38
pro_v3.5.1/crmeb/services/ai/storage/Ai.php
Normal file
38
pro_v3.5.1/crmeb/services/ai/storage/Ai.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\services\ai\storage;
|
||||
|
||||
use crmeb\basic\BaseAi;
|
||||
|
||||
class Ai extends BaseAi
|
||||
{
|
||||
const CONVERSATION = 'v2/chat/conversation';
|
||||
const CHAT = 'v2/chat/chat';
|
||||
|
||||
protected function initialize(array $config = [])
|
||||
{
|
||||
parent::initialize($config);
|
||||
}
|
||||
|
||||
public function chat(string $systemContent, string $userContent)
|
||||
{
|
||||
$param['messages'] = [
|
||||
[
|
||||
'role' => 'system',
|
||||
'content' => $systemContent
|
||||
],
|
||||
[
|
||||
'role' => 'user',
|
||||
'content' => $userContent
|
||||
]
|
||||
];
|
||||
$param['max_tokens'] = '4096';
|
||||
$param['temperature'] = '1';
|
||||
$param['frequency_penalty'] = '0';
|
||||
$param['presence_penalty'] = '0';
|
||||
$param['model'] = 'deepseek-chat';
|
||||
$param['response_format'] = '{ "type": "json_object" }';
|
||||
$result = $this->accessToken->httpRequest(self::CHAT, $param);
|
||||
return str_replace(['```json', '```'], '', $result['data']['choices'][0]['message']['content']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user