- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是我的 GPT-3 API 的工作代码。我在将其转换为与 chatGPT-3.5 一起使用时遇到问题。
<?php include('../config/config.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Chatbot</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container py-5">
<h1 class="mb-5 text-center">
<div class="logo"> <img src="/images/Logo-PocketAI.svg" height="80" width="210" aria-label="PocketAI.Online Logo" title="PocketAI.Online Logo" alt="SPocketAI.Online Logo" class="img-fluid"> </div>
</h1>
<div class="form-floating mb-3">
<select class="form-select" id="tab-select" aria-label="Select your purpose">
<option value="exam" selected>Exam</option>
<option value="feedback">Feedback</option>
</select>
<label for="tab-select">Select your purpose:</label>
</div>
<div class="input-group mb-3">
<div class="form-floating">
<textarea class="form-control" placeholder="Enter your question or comment here" id="prompt"></textarea>
<label for="prompt">Enter your question or comment here</label>
</div>
<div class="input-group-append username w-100 mt-3 mb-4">
<button class="btn btn-outline-primary w-100" type="button" id="send-button">Send</button>
</div>
</div>
<div id="output" class="mb-3" style="height: 300px; overflow: auto; border: 1px solid lightgray; padding: 10px;"></div>
<div id="exam-instructions" class="mb-3" style="display: block;">
<h3>Exam</h3>
<p>PocketAI can create multiple choice and true false questions in a format that enables import into Brightspace D2L quizzes using Respondus. Place PocketAI output into a Word document before importing with Respondus. Ask PocketAI questions like the following: <br>
<br>
Create 3 multiple choice questions about carbohydrates for a freshman Nutrition online college course.<br>
Create 2 true false questions about business for a sophomore Business face to face college course.</p>
</div>
<div id="feedback-instructions" class="mb-3" style="display: none;">
<h3>Feedback</h3>
<p>Enter text to receive writing feedback.</p>
</div>
</div>
<script>
const previousPrompts = [];
const userName = "<strong>User</strong>";
const chatbotName = "<strong>PocketAI</strong>";
const selectDropdown = document.getElementById("tab-select");
selectDropdown.addEventListener("change", function() {
const activeTabId = this.value;
// hide all instruction sections
document.querySelectorAll("[id$='-instructions']").forEach(function(instructionSection) {
instructionSection.style.display = "none";
});
// show the instruction section for the active tab
document.getElementById(`${activeTabId}-instructions`).style.display = "block";
});
document.getElementById("send-button").addEventListener("click", function() {
const prompt = document.getElementById("prompt").value;
const activeTabId = selectDropdown.value;
const endpoint = "https://api.openai.com/v1/completions";
const apiKey = "<?=$OPEN_AI_KEY;?>";
document.getElementById("send-button").innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Sending...';
let promptText = "";
switch (activeTabId) {
case "exam":
promptText = "Create quiz questions in the following format: Begin each question with a number followed by a period, and then include the question wording. For each question, include four answer choices listed as letters (A, B, C, D) followed by a period and at least one space before the answer wording. Designate the correct answer by placing an asterisk (*) directly in front of the answer letter (do not put a space between the asterisk and the answer choice). Place the asterisk in front of the answer letter, only the front. It is important that correct answers are identified. Don't make up answers, only select factual answers. For example formatting (don't use this specific example), \"1. What is the recommended daily intake of dietary fiber? A. 10 grams B. 25 grams *C. 50 grams D. 75 grams\". Format true false questions the same way. If you are unsure of the correct answer, don't create the question. Every quiz question and answer must be 100% correct and factual. Do not make up answers. All answers must be correct.";
break;
case "feedback":
promptText = "Can you provide feedback on the writing, grammar, sentence structure, punctuation, and style of this student's paper? The paper should be analyzed for its strengths and weaknesses in terms of written communication. Please provide suggestions for improvement and examples to help the student understand how to make the writing better. The feedback should be specific and provide actionable steps that the student can take to improve their writing skills. Please include at least three examples of areas that could be improved and specific suggestions for how to improve them, such as correcting grammar errors, restructuring sentences, or improving the use of punctuation.";
break;
}
const requestData = {
prompt: previousPrompts.join("\n") + promptText + "\n" + prompt,
max_tokens: 400,
model: "text-davinci-003",
n: 1,
stop: "",
temperature: 0.5,
top_p: 0.0,
frequency_penalty: 0.0,
presence_penalty: 0
};
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`,
},
body: JSON.stringify(requestData),
};
fetch(endpoint, requestOptions)
.then(response => response.json())
.then(data => {
const reply = data.choices[0].text;
// Add the user message to the chat history
const userMessage = `<div class="message-container">
<div class="username">${userName}: </div>
<div class="user-message">${prompt}</div>
</div>`;
document.getElementById("output").innerHTML += userMessage;
const chatbotMessage = `<div class="message-container">
<div class="username">${chatbotName}: </div>
<div class="chatbot-message" style="white-space: pre-wrap">${reply}<i class="bi bi-clipboard-check copy-button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Copy to clipboard" data-text="${reply}" style="cursor: pointer;"></i></div>
</div>`;
document.getElementById("output").innerHTML += chatbotMessage;
// Add an event listener to each "Copy to Clipboard" button
document.addEventListener("click", function(event) {
if (event.target.classList.contains("copy-button")) {
const textToCopy = event.target.dataset.text;
navigator.clipboard.writeText(textToCopy);
}
});
// Scroll to the bottom of the chat history
document.getElementById("output").scrollTop = document.getElementById("output").scrollHeight;
// Clear the user input field
document.getElementById("prompt").value = "";
previousPrompts.push(prompt);
// Clear the spinner and show the "Send" button again
document.getElementById("send-button").innerHTML = 'Send';
})
.catch(error => {
console.error(error);
// Hide the spinner and show the "Send" button again
document.getElementById("send-button").innerHTML = 'Send';
});
});
document.getElementById("prompt").addEventListener("keydown", function(event) {
if (event.keyCode === 13) {
event.preventDefault();
document.getElementById("send-button").
click();
}
});
</script>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>
我已阅读https://openai.com/blog/introducing-chatgpt-and-whisper-apis并提到这个 - OpenAI ChatGPT (gpt-3.5-turbo) API: How to access the message content?但仍然无法使其工作。
我尝试将 requestData 更改为此,但没有成功:
const requestData = {
model: "gpt-3.5-turbo",
messages: [
{ role: "user", content: prompt }
],
max_tokens: 400,
temperature: 0.5,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0
};
任何帮助将不胜感激!
最佳答案
更好地检查您的 requestData
对象,GPT 3.5 Turbo 不需要这些 Prop
max_tokens,temperature,top_p: 1,frequency_penalty,presence_penalty
我也犯了同样的错误,GPT 3.5 Turbo 比我想象的更容易使用。这是 OpenAI 示例:
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{role: "user", content: "Hello world"}],
});
console.log(completion.data.choices[0].message);
关于php - OpenAI 将 API 代码从 GPT-3 转换为 chatGPT-3.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75640144/
ChatGPT 以其强大的信息整合和对话能力惊艳了全球,在自然语言处理上面表现出了惊人的能力。这么强大的工具我们都想体验一下,那么 ChatGPT 怎么用呢?本文将给你逐步详细介绍。 Chat GPT
我有一个想法创建一个应用程序,可以通过chatgpt api绘制chatgpt讨论的思维导图。但是,如何编写一个提示来控制chatgpt写出固定格式的思维导图以便于解析呢? 最佳答案 这可以使用 Me
我有一个想法创建一个应用程序,可以通过chatgpt api绘制chatgpt讨论的思维导图。但是,如何编写一个提示来控制chatgpt写出固定格式的思维导图以便于解析呢? 最佳答案 这可以使用 Me
openAI/chatGPT也支持docx/pdf文件上传吗? 我想上传多个文件到 openAI/chatGPT。我尝试了 https://platform.openai.com/docs/api-r
openAI/chatGPT也支持docx/pdf文件上传吗? 我想上传多个文件到 openAI/chatGPT。我尝试了 https://platform.openai.com/docs/api-r
OpenAI/chat GPT也支持docx/pdf文件上传吗?。我想上传多个文件到openAI/chatGPT。我在https://platform.openai.com/docs/api-refe
1.概述 OpenAI 持续突破人工智能的边界,推出了其最新模型 ChatGPT-4o,作为 ChatGPT-4 的继承者,该模型有望带来显著的提升和创新功能。本文将深入解析 ChatGPT-4 与
ChatGPT 是OpenAI 发布的一个全新的聊天机器人模型。它到底有多厉害呢?我注册后体验了一下,你会感觉背后有个真人跟你在聊天。例如: 代码不仅可以运行,还特么有每行带有中文注释,这完全是降维打
ChatGPT+Mermaid语言实现技术概念可视化 本文旨在介绍如何使用ChatGPT和Mermaid语言生成流程图的技术。在现代软件开发中,流程图是一种重要的工具,用于可视化和呈现各种流程
当谈到人工智能技术的时候,我们会经常听到GPT这个术语。它代表“Generative Pre-trained Transformer”,是一种机器学习模型,采用了神经网络来模拟人类语言的理解
作者:京东科技 赵龙波 “贾维斯,你在吗?” “随时待命,先生。” 类似《钢铁侠》里的人工智能助理贾维斯,ChatGPT或许是你的随时待命的助手。ChatGPT在大量文本数据上进行
ChatGPT 火爆出圈,但是 OpenAI(开发 ChatGPT 的公司)却不对国内用户正式开放使用。但是,我们仍然有办法可以在第一时间体验到这个超强 AI。下面我来教你如何
最近的热门话题,OpenAI 推出的ChatGPT绝对榜上有名!但是不说注册难度,只说每次需要一些不可抗力的原因才能访问使用就很麻烦,大部分人无法体验到,本文介绍的方式直接对接个人微信(不是公众号)非
我正在从 ChatGPT API 中提取与单词列表相对应的单词嵌入。我想知道是否有一种类似于Gensimmost_similar方法的方法来提取整个模型中与我想要的术语最相似的n个单词。 最佳答案 是
有谁知道我是否可以使用 streamlit_chat 消息在 Streamlit 中显示类似 chatgpt 的流响应? 我需要类似 message(streaming=True) 或任何其他替代方案
我正在构建一个平台,用户可以在其中上传自定义数据并构建聊天机器人。 我正在考虑使用 lanchain + open ai embeddings + chat gpt api + pinecone 来管
我正在尝试设置函数来调用我最近一直在从事的一个项目,但我似乎无法让它工作 我查找了文档,但只找到了无法很好地解释它的 YouTube 视频。我尝试过运行各种示例,但没有任何效果对我有用。这就是我所拥有
我正在研究将 html 页面从一种语言翻译成另一种语言的想法——翻译可见文本(如果更具体的话)。我已经将 html 拆分为标记和文本 block ,现在我需要通过 ChatGPT 翻译文本。但对于我的
我正在研究将 html 页面从一种语言翻译成另一种语言的想法——翻译可见文本(如果更具体的话)。我已经将 html 拆分为标记和文本 block ,现在我需要通过 ChatGPT 翻译文本。但对于我的
我正在从 ChatGPT API 中提取与单词列表相对应的单词嵌入。我想知道是否有一种类似于Gensimmost_similar方法的方法来提取整个模型中与我想要的术语最相似的n个单词。 最佳答案 是
我是一名优秀的程序员,十分优秀!