<!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>&lt;script&gt;
	function getCompletions() {
		const prompt = document.getElementById(&quot;prompt&quot;).value;
		const keys = &quot;sk-xxx&quot;;
		const tips = &quot;你当前使用的模型为gpt-3.5-turbo!&quot;;

		axios.post(&quot;https://svip-api.cveoy.top/v4/completions&quot;, {
			prompt: prompt,
			keys: keys,
			tips: tips
		}, {
			responseType: &quot;stream&quot;
		})
		.then(response =&gt; {
			let stream = response.data;
			let reader = stream.getReader();
			let decoder = new TextDecoder();

			let result = &quot;&quot;;
			reader.read().then(function processText({ done, value }) {
				if (done) {
					document.getElementById(&quot;completions&quot;).innerHTML = result;
					return;
				}

				result += value;
				return reader.read().then(processText);
			});
		})
		.catch(error =&gt; {
			console.log(error);
		});
	}
&lt;/script&gt;
</code></pre>
</body>
</html
利用下面提供的接口与参数使用html写出网站接口 httpssvip-apicveoytopv4completions POST请求参数 	prompt 你好	keys sk-xxx	tips 你当前使用的模型为gpt-35-turbo!数据以stream方法返回

原文地址: http://www.cveoy.top/t/topic/c4MB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录