* add assistant for chat with ai.
This commit is contained in:
@@ -178,6 +178,7 @@ zentaoxx:
|
||||
echo "\$$config->xuanxuan->enabledMethods['im']['getaipermission'] = 'getAiPermission';" >> zentaoxx/config/ext/_0_xuanxuan.php
|
||||
echo "\$$config->xuanxuan->enabledMethods['im']['chatwithai'] = 'chatWithAi';" >> zentaoxx/config/ext/_0_xuanxuan.php
|
||||
echo "\$$config->xuanxuan->enabledMethods['im']['clearaichatcontext'] = 'clearAiChatContext';" >> zentaoxx/config/ext/_0_xuanxuan.php
|
||||
echo "\$$config->xuanxuan->enabledMethods['im']['getaiassistant'] = 'getAiAssistant';" >> zentaoxx/config/ext/_0_xuanxuan.php
|
||||
find zentaoxx/extension/xuan/ -name '*.php' -exec sed -i -r 's|->ne(["'\'']0000-00-00 00:00:00["'\''])|->notZeroDatetime()|g; s|["'\'']\)->eq\(["'\'']0000-00-00( 00:00:00)?| is null|g; s|([=!]=) ?["'\'']0000-00-00( 00:00:00)?["'\'']|\1 null|g; s|([^!=]=) ?["'\'']0000-00-00( 00:00:00)?["'\'']|\1 null|g; s|(["'\''])(,.*)\)->eq\(["'\'']0000-00-00( 00:00:00)?["'\'']| is null\1\2|g; s|["'\'']0000-00-00 00:00:00["'\'']|null|g' {} +
|
||||
mkdir zentaoxx/misc; cp misc/cn2tw.php zentaoxx/misc; cd zentaoxx/misc; php cn2tw.php
|
||||
cp misc/en2other.php zentaoxx/misc; cd zentaoxx/misc; php en2other.php ../
|
||||
|
||||
@@ -3,7 +3,7 @@ helper::import('../../control.php');
|
||||
|
||||
class myIm extends im
|
||||
{
|
||||
public function chatWithAi($modelId, $userID = 0, $version = '', $device = 'desktop')
|
||||
public function chatWithAi($modelId, $assistantId, $userID = 0, $version = '', $device = 'desktop')
|
||||
{
|
||||
$user = $this->im->user->getByID($userID);
|
||||
$user->rights = $this->loadModel('user')->authorize($user->account);
|
||||
@@ -31,6 +31,18 @@ class myIm extends im
|
||||
);
|
||||
}, $context);
|
||||
|
||||
if(!empty($assistantId))
|
||||
{
|
||||
$assistant = $this->ai->getAssistantById($assistantId);
|
||||
if($assistant)
|
||||
{
|
||||
array_unshift($context, (object)array(
|
||||
'role' => 'system',
|
||||
'content' => $assistant->systemMessage,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$messages = $this->ai->converse($modelId, $context);
|
||||
|
||||
if(!$messages)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
helper::import('../../control.php');
|
||||
|
||||
class myIm extends im
|
||||
{
|
||||
public function getAiAssistant($modelId, $userID = 0, $version = '', $device = 'desktop')
|
||||
{
|
||||
$assistants = $this->loadModel('ai')->getAssistantsByModel($modelId);
|
||||
|
||||
$output = new stdclass();
|
||||
$output->method = 'getaiassistant';
|
||||
$output->result = 'success';
|
||||
$output->data = $assistants;
|
||||
|
||||
return $this->im->sendOutput($output, 'getaiassistantResponse');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user