* add gpt4 to ai.
This commit is contained in:
@@ -4,7 +4,7 @@ $config->ai->vendorList['openai']['requiredFields'] = array('key');
|
||||
$config->ai->vendorList['azure']['requiredFields'] = array('key', 'resource', 'deployment');
|
||||
$config->ai->vendorList['baidu']['requiredFields'] = array('key', 'secret');
|
||||
|
||||
$config->ai->models = array('openai-gpt35' => 'openai', 'baidu-ernie' => 'ernie');
|
||||
$config->ai->models = array('openai-gpt35' => 'openai', 'openai-gpt4' => 'openai', 'baidu-ernie' => 'ernie');
|
||||
|
||||
/* OpenAI GPT configurations. */
|
||||
$config->ai->openai = new stdclass();
|
||||
@@ -34,8 +34,8 @@ $config->ai->openai->params->completion->required = array('prompt', 'max_tokens'
|
||||
$config->ai->openai->params->completion->optional = array('suffix', 'temperature', 'top_p', 'n', 'stream', 'logprobs', 'echo', 'stop', 'presence_penalty', 'frequency_penalty', 'best_of', 'logit_bias', 'user');
|
||||
|
||||
$config->ai->openai->model = new stdclass();
|
||||
$config->ai->openai->model->chat = 'gpt-3.5-turbo';
|
||||
$config->ai->openai->model->function = 'gpt-3.5-turbo';
|
||||
$config->ai->openai->model->chat = array('openai-gpt35' => 'gpt-3.5-turbo', 'openai-gpt4' => 'gpt-4-1106-preview');
|
||||
$config->ai->openai->model->function = array('openai-gpt35' => 'gpt-3.5-turbo', 'openai-gpt4' => 'gpt-4-1106-preview');
|
||||
$config->ai->openai->model->completion = 'gpt-3.5-turbo-instruct';
|
||||
|
||||
$config->ai->openai->contentTypeMapping = array('Content-Type: application/json' => array('', 'function', 'chat', 'completion'), 'Content-Type: multipart/form-data' => array());
|
||||
|
||||
@@ -145,7 +145,7 @@ class ai extends control
|
||||
|
||||
$this->ai->setConfig($modelConfig);
|
||||
|
||||
if($this->config->ai->models[$modelConfig->type] == 'ernie' || $currentVendor == 'azure')
|
||||
if($this->config->ai->models[$modelConfig->type] == 'ernie' || $currentVendor == 'azure' || $modelConfig->type == 'openai-gpt4')
|
||||
{
|
||||
$messages = array((object)array('role' => 'user', 'content' => 'test'));
|
||||
$result = $this->ai->converse($messages, array('maxTokens' => 1));
|
||||
|
||||
@@ -433,12 +433,17 @@ $lang->ai->models->statusList['off'] = 'Disable';
|
||||
|
||||
$lang->ai->models->typeList = array();
|
||||
$lang->ai->models->typeList['openai-gpt35'] = 'OpenAI / GPT-3.5';
|
||||
$lang->ai->models->typeList['openai-gpt4'] = 'OpenAI / GPT-4';
|
||||
$lang->ai->models->typeList['baidu-ernie'] = 'Baidu / ERNIE';
|
||||
|
||||
$lang->ai->models->vendorList = new stdclass();
|
||||
$lang->ai->models->vendorList->{'openai-gpt35'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'openai-gpt4'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'baidu-ernie'} = array('baidu' => 'Baidu Qianfan LLM Platform');
|
||||
|
||||
$lang->ai->models->vendorTips = new stdclass();
|
||||
$lang->ai->models->vendorTips->azure = 'OpenAI GPT version is specified during model deployment creation on Azure.';
|
||||
|
||||
$lang->ai->models->proxyTypes = array();
|
||||
$lang->ai->models->proxyTypes[''] = 'No Proxy';
|
||||
$lang->ai->models->proxyTypes['socks5'] = 'SOCKS5';
|
||||
|
||||
@@ -433,12 +433,17 @@ $lang->ai->models->statusList['off'] = 'Disable';
|
||||
|
||||
$lang->ai->models->typeList = array();
|
||||
$lang->ai->models->typeList['openai-gpt35'] = 'OpenAI / GPT-3.5';
|
||||
$lang->ai->models->typeList['openai-gpt4'] = 'OpenAI / GPT-4';
|
||||
$lang->ai->models->typeList['baidu-ernie'] = 'Baidu / ERNIE';
|
||||
|
||||
$lang->ai->models->vendorList = new stdclass();
|
||||
$lang->ai->models->vendorList->{'openai-gpt35'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'openai-gpt4'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'baidu-ernie'} = array('baidu' => 'Baidu Qianfan LLM Platform');
|
||||
|
||||
$lang->ai->models->vendorTips = new stdclass();
|
||||
$lang->ai->models->vendorTips->azure = 'OpenAI GPT version is specified during model deployment creation on Azure.';
|
||||
|
||||
$lang->ai->models->proxyTypes = array();
|
||||
$lang->ai->models->proxyTypes[''] = 'No Proxy';
|
||||
$lang->ai->models->proxyTypes['socks5'] = 'SOCKS5';
|
||||
|
||||
@@ -433,12 +433,17 @@ $lang->ai->models->statusList['off'] = 'Disable';
|
||||
|
||||
$lang->ai->models->typeList = array();
|
||||
$lang->ai->models->typeList['openai-gpt35'] = 'OpenAI / GPT-3.5';
|
||||
$lang->ai->models->typeList['openai-gpt4'] = 'OpenAI / GPT-4';
|
||||
$lang->ai->models->typeList['baidu-ernie'] = 'Baidu / ERNIE';
|
||||
|
||||
$lang->ai->models->vendorList = new stdclass();
|
||||
$lang->ai->models->vendorList->{'openai-gpt35'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'openai-gpt4'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'baidu-ernie'} = array('baidu' => 'Baidu Qianfan LLM Platform');
|
||||
|
||||
$lang->ai->models->vendorTips = new stdclass();
|
||||
$lang->ai->models->vendorTips->azure = 'OpenAI GPT version is specified during model deployment creation on Azure.';
|
||||
|
||||
$lang->ai->models->proxyTypes = array();
|
||||
$lang->ai->models->proxyTypes[''] = 'No Proxy';
|
||||
$lang->ai->models->proxyTypes['socks5'] = 'SOCKS5';
|
||||
|
||||
@@ -433,12 +433,17 @@ $lang->ai->models->statusList['off'] = '停用';
|
||||
|
||||
$lang->ai->models->typeList = array();
|
||||
$lang->ai->models->typeList['openai-gpt35'] = 'OpenAI / GPT-3.5';
|
||||
$lang->ai->models->typeList['openai-gpt4'] = 'OpenAI / GPT-4';
|
||||
$lang->ai->models->typeList['baidu-ernie'] = '百度 / 文心一言';
|
||||
|
||||
$lang->ai->models->vendorList = new stdclass();
|
||||
$lang->ai->models->vendorList->{'openai-gpt35'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'openai-gpt4'} = array('openai' => 'OpenAI', 'azure' => 'Azure');
|
||||
$lang->ai->models->vendorList->{'baidu-ernie'} = array('baidu' => '百度千帆大模型平台');
|
||||
|
||||
$lang->ai->models->vendorTips = new stdclass();
|
||||
$lang->ai->models->vendorTips->azure = 'Azure 中 OpenAI GPT 版本 (3.5 或 4) 需要在创建资源时指定。';
|
||||
|
||||
$lang->ai->models->proxyTypes = array();
|
||||
$lang->ai->models->proxyTypes[''] = '不使用代理';
|
||||
$lang->ai->models->proxyTypes['socks5'] = 'SOCKS5';
|
||||
|
||||
+5
-1
@@ -238,8 +238,12 @@ class aiModel extends model
|
||||
{
|
||||
$modelType = $this->config->ai->models[$this->modelConfig->type];
|
||||
|
||||
/* Models of the same type may differ in version, in which case they are stored as an array. */
|
||||
$modelName = $this->config->ai->$modelType->model->$type;
|
||||
if(is_array($modelName)) $modelName = $modelName[$this->modelConfig->type];
|
||||
|
||||
$postData = new stdclass();
|
||||
$postData->model = $this->config->ai->$modelType->model->$type;
|
||||
$postData->model = $modelName;
|
||||
|
||||
$data = static::standardizeParams($data);
|
||||
|
||||
|
||||
@@ -16,36 +16,43 @@ $requiredFields = $config->ai->vendorList[$currentVendor]['requiredFields'];
|
||||
if(empty($requiredFields)) $requiredFields = array();
|
||||
js::set('vendorList', $config->ai->vendorList);
|
||||
js::set('vendorListLang', $lang->ai->models->vendorList);
|
||||
js::set('vendorTipsLang', $lang->ai->models->vendorTips);
|
||||
?>
|
||||
<style>
|
||||
.required:after {right: -12px;}
|
||||
</style>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<form id='mainForm' class='load-indicator main-form form-ajax' method='post'>
|
||||
<table class='table table-form mw-800px'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->type;?></th>
|
||||
<td><?php echo html::select('type', $lang->ai->models->typeList, $modelConfig->type, "class='form-control chosen' required");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->vendor;?></th>
|
||||
<td><?php echo html::select('vendor', $lang->ai->models->vendorList->{empty($modelConfig->type) ? key($lang->ai->models->typeList) : $modelConfig->type}, $currentVendor, "class='form-control chosen' required");?></td>
|
||||
<td id='vendor-tips' class='text-gray' style='display: none;'></td>
|
||||
</tr>
|
||||
<tr class="vendor-row <?php echo in_array('key', $requiredFields) ? '' : ' hidden'; ?>" data-vendor-field="key">
|
||||
<th><?php echo $lang->ai->models->key;?></th>
|
||||
<td><?php echo html::input('key', $modelConfig->key, "class='form-control' required");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="vendor-row <?php echo in_array('secret', $requiredFields) ? '' : ' hidden'; ?>" data-vendor-field="secret">
|
||||
<th><?php echo $lang->ai->models->secret;?></th>
|
||||
<td><?php echo html::input('secret', $modelConfig->secret, "class='form-control' required");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="vendor-row <?php echo in_array('resource', $requiredFields) ? '' : ' hidden'; ?>" data-vendor-field="resource">
|
||||
<th><?php echo $lang->ai->models->resource;?></th>
|
||||
<td><?php echo html::input('resource', empty($modelConfig->resource) ? '' : $modelConfig->resource, "class='form-control' required");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="vendor-row <?php echo in_array('deployment', $requiredFields) ? '' : ' hidden'; ?>" data-vendor-field="deployment">
|
||||
<th><?php echo $lang->ai->models->deployment;?></th>
|
||||
<td><?php echo html::input('deployment', empty($modelConfig->deployment) ? '' : $modelConfig->deployment, "class='form-control' required");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->proxyType;?></th>
|
||||
@@ -62,14 +69,17 @@ js::set('vendorListLang', $lang->ai->models->vendorList);
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->description;?></th>
|
||||
<td><?php echo html::textarea('description', $modelConfig->description, "class='form-control'");?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->statusAB;?></th>
|
||||
<td><?php echo html::radio('status', $lang->ai->models->statusList, empty($modelConfig->status) ? 'on' : $modelConfig->status);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='text-center'>
|
||||
@@ -77,6 +87,7 @@ js::set('vendorListLang', $lang->ai->models->vendorList);
|
||||
<?php echo html::commonButton($lang->ai->models->testConnection, 'id="testConn"', 'btn btn-secondary btn-wide');?>
|
||||
<?php echo html::a(inlink('models', ""), $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
@@ -96,6 +107,8 @@ $(function() {
|
||||
{
|
||||
var vendor = $(this).val();
|
||||
var requiredFields = vendorList[vendor]['requiredFields'];
|
||||
const vendorTip = vendorTipsLang[vendor];
|
||||
$('#vendor-tips').html(vendorTip ? vendorTip : '').toggle(!!vendorTip);
|
||||
$('.vendor-row').each(function()
|
||||
{
|
||||
var name = $(this).data('vendor-field');
|
||||
|
||||
Reference in New Issue
Block a user