利用下面提供的接口与参数使用html写出网站接口 httpssvip-apicveoytopv4completions POST请求参数 prompt 你好 keys sk-xxx tips 你当前使用的模型为gpt-35-turbo!数据以stream方法返回
<!DOCTYPE html>
<html>
<head>
<title>自动补全</title>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<h1>自动补全</h1>
<p>输入提示语句:</p>
<input type="text" id="prompt">
<button onclick="getCompletions()">获取补全结果</button>
<br><br>
<p>补全结果:</p>
<ul id="completions"></ul>
<pre><code><script>
function getCompletions() {
const prompt = document.getElementById("prompt").value;
const keys = "sk-xxx";
const tips = "你当前使用的模型为gpt-3.5-turbo!";
axios.post("https://svip-api.cveoy.top/v4/completions", {
prompt: prompt,
keys: keys,
tips: tips
}, {
responseType: "stream"
})
.then(response => {
let stream = response.data;
let reader = stream.getReader();
let decoder = new TextDecoder();
let result = "";
reader.read().then(function processText({ done, value }) {
if (done) {
document.getElementById("completions").innerHTML = result;
return;
}
result += value;
return reader.read().then(processText);
});
})
.catch(error => {
console.log(error);
});
}
</script>
</code></pre>
</body>
</html
原文地址: http://www.cveoy.top/t/topic/c4MB 著作权归作者所有。请勿转载和采集!