AI代码生成工具

This commit is contained in:
李琦
2026-08-10 15:51:00 +08:00
parent d0018a0173
commit bd226c260f
31 changed files with 5468 additions and 31 deletions

20
config/ai.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
/**
* AI 供应商环境回落配置(库内未配置密钥/地址时使用)
*/
return [
'default_provider' => env('AI_DEFAULT_PROVIDER', 'deepseek'),
'spark' => [
'api_url' => env('SPARK_API_URL', 'https://spark-api-open.xf-yun.com/v1/chat/completions'),
'password' => env('SPARK_API_PASSWORD', ''),
'model' => env('SPARK_API_MODEL', 'lite'),
'timeout' => (float) env('SPARK_API_TIMEOUT', 60),
],
'deepseek' => [
'api_url' => env('DEEPSEEK_API_URL', 'https://api.deepseek.com/v1/chat/completions'),
'api_key' => env('DEEPSEEK_API_KEY', ''),
'model' => env('DEEPSEEK_API_MODEL', 'deepseek-chat'),
'timeout' => (float) env('DEEPSEEK_API_TIMEOUT', 60),
],
];

View File

@@ -397,7 +397,7 @@ if(!function_exists('ase_encode')) {
function ase_encode($str)
{
if (empty($str)) return $str;
return base64_encode(\Illuminate\Support\Str::random(config('ase.len')). base64_encode($str));
return base64_encode(\Illuminate\Support\Str::random(config('nl.ase_len', 30)). base64_encode($str));
}
}
@@ -411,7 +411,7 @@ if (!function_exists('ase_decode')) {
{
if (empty($str)) return $str?? '';
$result = base64_decode($str);
$result = base64_decode(substr($result, config('ase.len')));
$result = base64_decode(substr($result, config('nl.ase_len', 30)));
$pattern = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\xFF]|[\x{E000}-\x{F8FF}]/u';
if (preg_match($pattern, $result)) return $str;
return $result;

View File

@@ -24,17 +24,26 @@ return [
'jwt' => [
'secret' => env('JWT_SECRET', 'nl_admin_jwt_secret_key_change_me_32b'),
],
/*
* 库内敏感字段 AES 密钥(密文前缀 nl_ase_256_读取兼容历史 ***
* 对应 .envENCRYPT_KEY
*/
'encrypt_key' => env('ENCRYPT_KEY', ''),
/*
* 传输层 ase_encode / ase_decode 随机盐长度(与历史 helpers 兼容)
*/
'ase_len' => (int) env('ASE_LEN', 30),
/*
* redis配置
*/
'redis' => [
'jwt' => 'xk_login_',
'jwt' => 'nl_login_',
'jwt_ttl' => 360000,
// 'jwt_ttl' => 360,
'email' => 'xk_email_',
'phone' => 'xk_phone_',
'login_out_key' => 'xk_login_out_',
'menu_key' => 'xk_menu_',
'email' => 'nl_email_',
'phone' => 'nl_phone_',
'login_out_key' => 'nl_login_out_',
'menu_key' => 'nl_menu_',
],
/*
* api白名单
@@ -49,7 +58,7 @@ return [
* 阿里云oss配置
*/
'oss' => [
'redis_key' => 'xk_oss_url_',
'redis_key' => 'nl_oss_url_',
'ali' => [
'accessKeyId' => env('OSS_ACCESS_KEY_ID'),
'accessKeySecret' => env('OSS_ACCESS_KEY_SECRET'),