Skip to content

/dialogs/ai.html 可以直接换成简单的 也不用什么配置文件.js之类的。方便些 #44

Description

@6000168-png
<title>AI</title>
输入问题: <textarea title="请输入问题" id="prompt" class="form-control" rows="3">你好</textarea>
发送给 AI
AI 返回结果:
<script> async function sendAi() { const prompt = document.getElementById('prompt').value.trim(); const resultDiv = document.getElementById('result'); if (!prompt) { resultDiv.innerHTML = '请输入内容'; return; } try { // ✅ 调用你的接口 const response = await fetch(`/ai/chat?prompt=${encodeURIComponent(prompt)}`, { method: 'Post', cache: 'no-cache' }); // ✅ 获取 JSON const data = await response.json(); console.log('返回数据:', data); // ✅ 显示结果 const answer = data?.choices?.[0]?.message?.content || '无返回内容'; resultDiv.innerHTML = answer.replace(/\n/g, '
'); } catch (err) { resultDiv.innerHTML = `错误:${err.message}
${String(err)}`; console.error(err); } } </script>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions