文心一言 

类型
» CMS程序
标识
WenxinSkycaiji
下载
105次
更新
2024-05-15

调用文心一言生成文本

<?php
namespace plugin\api\process;

/**
 * 文心一言
 */
class WenxinSkycaiji{
	/*最终数据配置*/
	public $_content = <<<EOF
[变量:返回数据]
EOF;
	/*操作流程配置*/
	public $_ops = array (
		array (
			'module' => 'variable',
			'config' =>array (
				'name' => 'API_KEY',
				'desc' => '',
				'module' => 'user',
				'user' =>array (
					'required' => '1',
					'global' => '1',
					'tag' => 'text',
					'tag_select' => '',
					'default' => '',
				),
				'func' =>array (
					'open' => '0',
					'names' =>array (
					),
					'params' =>array (
					),
				),
			),
		), 
		array (
			'module' => 'variable',
			'config' =>array (
				'name' => 'SECRET_KEY',
				'desc' => '',
				'module' => 'user',
				'user' =>array (
					'required' => '1',
					'global' => '1',
					'tag' => 'text',
					'tag_select' => '',
					'default' => '',
				),
				'func' =>array (
					'open' => '0',
					'names' =>array (
					),
					'params' =>array (
					),
				),
			),
		), 
		array (
			'module' => 'request',
			'config' =>array (
				'name' => 'token',
				'url' => 'https://aip.baidubce.com/oauth/2.0/token',
				'charset' => '',
				'charset_custom' => '',
				'encode' => '',
				'encode_custom' => '',
				'type' => 'post',
				'content_type' => '',
				'param_names' =>array (
					0 => 'grant_type',
					1 => 'client_id',
					2 => 'client_secret',
				),
				'param_vals' =>array (
					0 => 'client_credentials',
					1 => '[变量:API_KEY]',
					2 => '[变量:SECRET_KEY]',
				),
				'timeout' => '',
				'interval' => '',
				'wait' => '',
				'retry' => '',
				'cache' => '',
			),
		), 
		array (
			'module' => 'variable',
			'config' =>array (
				'name' => 'token值',
				'desc' => '',
				'module' => 'extract',
				'extract' =>array (
					'source' => 'request:token',
					'type' => 'json',
					'json' => 'access_token',
					'json_arr' => 'implode',
					'json_arr_implode' => '',
					'rule' => '',
					'rule_merge' => '',
					'rule_multi_str' => '',
					'xpath' => '',
					'xpath_attr' => '',
					'xpath_attr_custom' => '',
					'xpath_multi_str' => '',
				),
				'func' =>array (
					'open' => '0',
					'names' =>array (
					),
					'params' =>array (
					),
				),
			),
		), 
		array (
			'module' => 'variable',
			'config' =>array (
				'name' => '输入内容',
				'desc' => '',
				'module' => 'user',
				'user' =>array (
					'required' => '0',
					'global' => '0',
					'tag' => 'text',
					'tag_select' => '',
					'default' => '',
				),
				'func' =>array (
					'open' => '0',
					'names' =>array (
					),
					'params' =>array (
					),
				),
			),
		), 
		array (
			'module' => 'request',
			'config' =>array (
				'name' => 'api',
				'url' => 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=[变量:token值]',
				'charset' => '',
				'charset_custom' => '',
				'encode' => '',
				'encode_custom' => '',
				'type' => 'post',
				'content_type' => 'application/json',
				'param_names' =>array (
					0 => 'messages.0.role',
					1 => 'messages.0.content',
					2 => 'temperature',
					3 => 'top_p',
				),
				'param_vals' =>array (
					0 => 'user',
					1 => '[变量:输入内容]',
					2 => '1.0',
					3 => '1.0',
				),
				'timeout' => '',
				'interval' => '',
				'wait' => '',
				'retry' => '',
				'cache' => '',
			),
		), 
		array (
			'module' => 'variable',
			'config' =>array (
				'name' => '返回数据',
				'desc' => '',
				'module' => 'extract',
				'extract' =>array (
					'source' => 'request:api',
					'type' => 'json',
					'json' => 'result',
					'json_arr' => 'implode',
					'json_arr_implode' => '',
					'rule' => '',
					'rule_merge' => '',
					'rule_multi_str' => '',
					'xpath' => '',
					'xpath_attr' => '',
					'xpath_attr_custom' => '',
					'xpath_multi_str' => '',
				),
				'func' =>array (
					'open' => '0',
					'names' =>array (
					),
					'params' =>array (
					),
				),
			),
		),
	);
}