refactor(easy-admin): improve AI optimization feature and enhance user experience

- Remove line-height style from AI optimization content div
- Add smooth scrolling to the end of the content when streaming output Move input validation to the beginning of the aiOptimization function
This commit is contained in:
wolfcode
2025-03-10 11:54:41 +08:00
parent 51f2cbc0f4
commit a7a3ddef8b
2 changed files with 5 additions and 3 deletions

View File

@@ -79,6 +79,9 @@ class Goods extends AdminController
#[NodeAnnotation(title: 'AI优化', auth: true)]
public function aiOptimization(Request $request): void
{
$message = $request->post('message');
if (empty($message)) $this->error('请输入内容');
// 演示环境下 默认返回的内容
if ($this->isDemo) {
$content = <<<EOF
@@ -104,8 +107,6 @@ EOF;
$this->success('success', compact('choices'));
}
$message = $request->post('message');
if (empty($message)) $this->error('请输入内容');
try {
$result = AiChatService::instance()
// 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0