* [story #79425] support for setting form for collecting data from user in zentao prompt.
This commit is contained in:
@@ -609,6 +609,15 @@ class ai extends control
|
||||
$response['dataPropNames'] = $this->lang->ai->dataSource[$prompt->module];
|
||||
}
|
||||
|
||||
$fields = array_values($this->ai->getPromptFields($promptId));
|
||||
if($fields)
|
||||
{
|
||||
$response['fields'] = $fields;
|
||||
$response['formConfig'] = [];
|
||||
$response['formConfig']['title'] = $this->lang->ai->prompts->formDefaultTitle;
|
||||
$response['formConfig']['submitBtnText'] = $this->lang->ai->prompts->formSubmitBtnText;
|
||||
}
|
||||
|
||||
$response['objectID'] = $objectId;
|
||||
$response['objectType'] = $prompt->module;
|
||||
$response['object'] = $objectData;
|
||||
|
||||
@@ -203,6 +203,10 @@ $lang->ai->prompts->selectTargetFormTip = 'Results returned from LLMs can be dir
|
||||
$lang->ai->prompts->goingTesting = 'Redirecting to testing page';
|
||||
$lang->ai->prompts->goingTestingFail = 'No testable object available.';
|
||||
|
||||
/* Prompt form settings. */
|
||||
$lang->ai->prompts->formDefaultTitle = 'Please fill in the following form content:';
|
||||
$lang->ai->prompts->formSubmitBtnText = 'Generate';
|
||||
|
||||
$lang->ai->prompts->testData['product']['product']['name'] = 'Corporate Website Construction Platform';
|
||||
$lang->ai->prompts->testData['product']['product']['desc'] = 'The Corporate Website Construction Platform is a management platform designed specifically for modern enterprises, aimed at helping companies showcase themselves in a professional and innovative manner. The platform integrates the latest corporate news, project achievements, contact information, and business details, allowing visitors to easily understand the core values and services of the company. With a clear and concise interface and intuitive navigation, the platform enhances user experience and helps build closer connections between businesses and their customers and partners. Whether for information updates or content management, the platform provides efficient and flexible solutions for enterprises, supporting brand building and business development.';
|
||||
|
||||
|
||||
@@ -203,6 +203,10 @@ $lang->ai->prompts->selectTargetFormTip = 'Results returned from LLMs can be dir
|
||||
$lang->ai->prompts->goingTesting = 'Redirecting to testing page';
|
||||
$lang->ai->prompts->goingTestingFail = 'No testable object available.';
|
||||
|
||||
/* Prompt form settings. */
|
||||
$lang->ai->prompts->formDefaultTitle = 'Please fill in the following form content:';
|
||||
$lang->ai->prompts->formSubmitBtnText = 'Generate';
|
||||
|
||||
$lang->ai->prompts->testData['product']['product']['name'] = 'Corporate Website Construction Platform';
|
||||
$lang->ai->prompts->testData['product']['product']['desc'] = 'The Corporate Website Construction Platform is a management platform designed specifically for modern enterprises, aimed at helping companies showcase themselves in a professional and innovative manner. The platform integrates the latest corporate news, project achievements, contact information, and business details, allowing visitors to easily understand the core values and services of the company. With a clear and concise interface and intuitive navigation, the platform enhances user experience and helps build closer connections between businesses and their customers and partners. Whether for information updates or content management, the platform provides efficient and flexible solutions for enterprises, supporting brand building and business development.';
|
||||
|
||||
|
||||
@@ -203,6 +203,10 @@ $lang->ai->prompts->selectTargetFormTip = 'Results returned from LLMs can be dir
|
||||
$lang->ai->prompts->goingTesting = 'Redirecting to testing page';
|
||||
$lang->ai->prompts->goingTestingFail = 'No testable object available.';
|
||||
|
||||
/* Prompt form settings. */
|
||||
$lang->ai->prompts->formDefaultTitle = 'Please fill in the following form content:';
|
||||
$lang->ai->prompts->formSubmitBtnText = 'Generate';
|
||||
|
||||
$lang->ai->prompts->testData['product']['product']['name'] = 'Corporate Website Construction Platform';
|
||||
$lang->ai->prompts->testData['product']['product']['desc'] = 'The Corporate Website Construction Platform is a management platform designed specifically for modern enterprises, aimed at helping companies showcase themselves in a professional and innovative manner. The platform integrates the latest corporate news, project achievements, contact information, and business details, allowing visitors to easily understand the core values and services of the company. With a clear and concise interface and intuitive navigation, the platform enhances user experience and helps build closer connections between businesses and their customers and partners. Whether for information updates or content management, the platform provides efficient and flexible solutions for enterprises, supporting brand building and business development.';
|
||||
|
||||
|
||||
@@ -203,6 +203,10 @@ $lang->ai->prompts->selectTargetFormTip = '选择后,可以将大语言模型
|
||||
$lang->ai->prompts->goingTesting = '即将跳转至调试页面';
|
||||
$lang->ai->prompts->goingTestingFail = '暂无可调试的对象';
|
||||
|
||||
/* Prompt form settings. */
|
||||
$lang->ai->prompts->formDefaultTitle = '请补充下列表单内容:';
|
||||
$lang->ai->prompts->formSubmitBtnText = '生成';
|
||||
|
||||
$lang->ai->prompts->testData['product']['product']['name'] = '企业网站建设平台';
|
||||
$lang->ai->prompts->testData['product']['product']['desc'] = '企业网站建设平台是一个专为现代企业设计的官网管理平台,旨在帮助公司以专业、创新的方式展示自我。该平台整合了最新的企业动态、项目成果、联系方式以及工商信息,让访客能够一目了然地了解公司的核心价值和服务。通过清晰简洁的界面和直观的导航,企业在线视窗提升了用户体验,帮助企业与客户和合作伙伴之间建立更紧密的联系。无论是信息更新还是内容管理,企业在线视窗都为企业提供了高效、灵活的解决方案,助力品牌建设与业务发展。';
|
||||
|
||||
|
||||
+2
-2
@@ -2088,7 +2088,7 @@ class aiModel extends model
|
||||
*/
|
||||
public static function assemblePrompt($prompt, $dataPrompt)
|
||||
{
|
||||
$wholePrompt = "$dataPrompt\n";
|
||||
$wholePrompt = empty($dataPrompt) ? '' : "$dataPrompt\n";
|
||||
|
||||
$wholePrompt .= static::tryPunctuate($prompt->role);
|
||||
$wholePrompt .= static::autoPrependNewline(static::tryPunctuate($prompt->characterization, true));
|
||||
@@ -2120,7 +2120,7 @@ class aiModel extends model
|
||||
$dataPrompt = $this->serializeDataToPrompt($prompt->module, $prompt->source, $objectData);
|
||||
if(empty($dataPrompt)) return -3;
|
||||
|
||||
$wholePrompt = static::assemblePrompt($prompt, $dataPrompt);
|
||||
$wholePrompt = static::assemblePrompt($prompt, '');
|
||||
$schema = $this->getFunctionCallSchema($prompt->targetForm);
|
||||
if(empty($schema)) return -5;
|
||||
|
||||
|
||||
@@ -43,6 +43,23 @@ window.openPageForm = function(url, data, callback)
|
||||
});
|
||||
}
|
||||
|
||||
function getPromptFormConfig(fields, extraConfig)
|
||||
{
|
||||
if(!Array.isArray(fields) || !fields.length) return;
|
||||
const typeMap = {text: 'string'};
|
||||
const required = [];
|
||||
const properties = fields.reduce((properties, field, index) => {
|
||||
properties[field.name] = {type: typeMap[field.type] || 'string', title: field.name, description: field.placeholder};
|
||||
if(field.required) required.push(field.name);
|
||||
return properties;
|
||||
}, {});
|
||||
return $.extend(
|
||||
{
|
||||
schema: {type: 'object', properties: properties, required: required},
|
||||
prompt: (data) => fields.map(x => `* ${x.name}: ${data[x.name] || ''}`).join('\n')
|
||||
}, extraConfig);
|
||||
}
|
||||
|
||||
window.executeZentaoPrompt = async function(info, testingMode)
|
||||
{
|
||||
testingMode = testingMode && testingMode !== '0';
|
||||
|
||||
Reference in New Issue
Block a user