题意:“从 R 访问 OpenAI (JSON) API”
问题背景:
I want to access the OpenAI API with the following curl command from R:
“我想从 R 中使用以下 curl 命令访问 OpenAI API:”
curl https://api.openai.com/v1/engines/davinci/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"prompt": "This is a test", "max_tokens": 5}'
I think the curl package (on CRAN) will be the best option(?). I have never used this package so can anyone help me getting started with this simple call?
“我认为 curl 包(在 CRAN 上)可能是最好的选择(?)。我从未使用过这个包,有人能帮我开始这个简单的调用吗?”
问题解决:
I created an R package named "openapi" (https://github.com/zhanghao-njmu/openapi), which supports all OpenAI APIs and can generate streaming returns (currently, other packages do not have good solutions), chatGPT app, and various RStudio add-ins. Welcome to use it.
“我创建了一个名为 `openapi` 的 R 包(https://github.com/zhanghao-njmu/openapi),它支持所有 OpenAI API,并且可以生成流式返回(目前其他包没有好的解决方案),还包括 chatGPT 应用程序和各种 RStudio 插件。欢迎使用。”