How can I load the openai api configuration through js in html?

server/2024/10/18 6:03:36/
html" title=ai>aidu_pl">
htmledit_views">

题意:怎样在HTML中通过JavaScript加载OpenAI API配置

问题背景:

I am trying to send a request through js in my html so that openhtml" title=ai>ai analyzes it and sends a response, but if in the js I put the following:

我正在尝试通过HTML中的JavaScript发送一个请求,以便让OpenAI分析它并发送响应,但如果我在JavaScript中放入以下内容:

html" title=javascript>javascript">const { Configuration, OpenAIApi } = require("openhtml" title=ai>ai");const configuration = new Configuration({
apiKey: "sk-0000000000000ZXXXXXXXXXXXXXX",
});
const openhtml" title=ai>ai = new OpenAIApi(configuration);async function test() {
console("test")
const response = awhtml" title=ai>ait openhtml" title=ai>ai.createCompletion("text-davinci-002", {
prompt: "hello",
temperature: 0.7,
max_tokens: 64,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
});
console.log(response)
}
test();

return console these error        在控制台返回错误信息

html" title=javascript>javascript">Uncaught ReferenceError: require is not defined
at buttons.js:94:38

I have tried to install it with node.js and it works fine but I don't know how to make it work in my own html

“我已经尝试使用node.js安装它,并且它工作正常,但我不知道如何在我的HTML中使其工作”

问题解决:

Posting the correct link that currently works:

“发布当前有效的正确链接:”

var url = "https://api.openhtml" title=ai>ai.com/v1/completions";

and here is how the data should look like for question answering with davinchi-003 engine:

“以下是使用davinci-003引擎进行问答时数据应有的样子:”

html" title=javascript>javascript">var data = `{"model": "text-davinci-003","prompt": "${prompt_text+question_out}","temperature": 0.9,"max_tokens": 150,"top_p": 1,"frequency_penalty": 0.0,"presence_penalty": 0.6,"stop": [" Human:", " AI:"]}`;

here the prompt_text is the prompt text I sent o the engine and question_out is the question I want the engine to answer based on the prompt.

“在这里,prompt_text 是我发送给引擎的提示文本,而 question_out 是我希望引擎根据提示来回答的问题。”


http://www.ppmy.cn/server/116960.html

相关文章

​睿​联​一​面​

1. 请尽可能详细地说明,ES6之后有哪些新特性?按照最近出现时间的顺序列举。你的回答中不要写出示例代码。 自ES6(ECMAScript 2015)发布以来,JavaScript 引入了许多新特性。以下是按时间顺序列出的一些主要新特性&…

鼎捷新一代PLM 荣膺维科杯 “2023年度行业优秀产品奖”

近日,由中国高科技行业门户OFweek维科网主办的“全数会2024(第五届)中国智能制造数字化转型大会暨维科杯工业自动化及数字化行业年度评选颁奖典礼”在深圳隆重举办。这不仅是中国工业自动化及数字化行业的一大品牌盛会,亦是高科技…

IOS Siri和快捷指令打开app

使用场景 需要Siri打开应用或者在自定义快捷指令打开应用,并携带内容进入应用。 1.创建Intents文件 1.1 依次点开File->New->File 1.2 搜索intent关键字找到 SiriKit Intent Definition File文件 1.3 找到刚才创建的Intent文件,点击然后New Inte…

C#复习之内部类和分布类

知识点一:内部类 知识点二:分布类 知识点三:分部方法

《2024中国数据要素产业图谱2.0版》重磅发布

数据猿出品 本次“数据猿2024年度三大媒体策划活动——《2024中国数据要素产业图谱2.0版》”的发布,下一次版本迭代将于2024年12月底发布2024年3.0版,敬请期待,欢迎报名。 大数据产业创新服务媒体 ——聚焦数据 改变商业 随着技术不断革新&a…

[数据集][目标检测]乱堆物料检测数据集VOC+YOLO格式1143张1类别

数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数):1143 标注数量(xml文件个数):1143 标注数量(txt文件个数):1143 标注…

Mysql 的查询过慢如何排查以及优化

1.慢查询: (1).查看慢查询的日志文件有没有打开:show variables like ‘slow_query_log’; (2).因为默认是没有开启的所以一般我们需要手动的去开启:set global slow_query_logon; (3).查看慢查询的时间:show variables like ‘…

【BUG报错已解决】`ERROR: Failed building wheel for jupyter-nbextensions-configurator`

🎬 鸽芷咕:个人主页 🔥 个人专栏: 《C干货基地》《粉丝福利》 ⛺️生活的理想,就是为了理想的生活! 文章目录 前言一、问题描述1.1 报错示例1.2 报错分析1.3 解决思路 二、解决方法2.1 方法一:安装编译工具和依赖项2.…