作者 刘锟

update

... ... @@ -260,7 +260,7 @@ class SyncInquiryRelay extends Command
//重写询盘内容
$ai_message_list = [];
for ($i = 0; $i < count($forward_list); $i++) {
$message_re = $inquiryForwardLogic->aiRewrite($data['message']);
$message_re = $inquiryForwardLogic->aiRewrite($data['message'], $data['title'], $keywords);
if (isset($message_re['ai_message']) && $message_re['ai_message']) {
$ai_message_list[] = $message_re['ai_message'];
}
... ...
... ... @@ -328,15 +328,22 @@ class InquiryForwardLogic extends BaseLogic
/**
* AI重写询盘文案
* @param $in_content
* @param $title
* @param $keywords
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2025/02/27 10:40
*/
public function aiRewrite($in_content)
public function aiRewrite($in_content, $title = '', $keywords = '')
{
$ai_info = AiCommand::select(['ai', 'not_use_probability'])->where('key', 'inquiry_text_rewrite')->first();
if ($title && $keywords) {
$command_key = 'inquiry_text_rewrite_v2';
} else {
$command_key = 'inquiry_text_rewrite';
}
$ai_info = AiCommand::select(['ai', 'not_use_probability'])->where('key', $command_key)->first();
if (!$ai_info) {
$this->fail('AI重写指令未配置');
}
... ... @@ -358,6 +365,10 @@ class InquiryForwardLogic extends BaseLogic
$lang = 'en';
}
if ($title && $keywords) {
$ai_command = str_replace('{title}', $title, $ai_command);
$ai_command = str_replace('{keywords}', $keywords, $ai_command);
}
$ai_command = str_replace('{incontent}', Arr::random(explode("\r\n", $in_content)), $ai_command);
$text = Gpt::instance()->openai_chat_qqs($ai_command);
... ...