first commit
This commit is contained in:
45
admin/class/smarty_plugins/function.insert_llm_button.php
Normal file
45
admin/class/smarty_plugins/function.insert_llm_button.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {insert_llm_button} plugin.
|
||||
*
|
||||
* Purpose: Insert llm button
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $smarty template object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_insert_llm_button($params, $smarty)
|
||||
{
|
||||
if (!findModule(Modules::LLM)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$textObjectUtil = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\LLMBundle\Util\TextObjectUtil::class);
|
||||
|
||||
$params['actions'] = [];
|
||||
|
||||
foreach ($textObjectUtil->getObjectLabelPrompts($params['type']) as $id => $prompt) {
|
||||
$json = [
|
||||
'entityType' => $params['entityType'] ?? substr(getVal('s'), 0, -4),
|
||||
'entityId' => $params['entityId'] ?? getVal('ID'),
|
||||
'target' => $params['target'],
|
||||
'promptId' => $id,
|
||||
'objectLabel' => $params['type'] ?? '',
|
||||
'title' => $prompt->getTitle(),
|
||||
];
|
||||
|
||||
$params['actions'][] = [
|
||||
'id' => $id,
|
||||
'title' => $prompt->getTitle(),
|
||||
'json' => $json,
|
||||
];
|
||||
}
|
||||
|
||||
echo $smarty->_subTemplateRender('llm/text-dropdown.tpl', $smarty->cache_id, $smarty->compile_id, 0, null, $params, 0, false);
|
||||
}
|
||||
Reference in New Issue
Block a user