{"id":24,"date":"2023-07-14T18:12:27","date_gmt":"2023-07-14T09:12:27","guid":{"rendered":"https:\/\/www.pinkgold.space\/?p=24"},"modified":"2024-09-23T17:16:07","modified_gmt":"2024-09-23T08:16:07","slug":"openai-platform-examples-%e4%be%8b%e6%96%87%e3%82%92%e8%a9%a6%e3%81%99%e6%97%85-summarize-for-a-2nd-grader","status":"publish","type":"post","link":"https:\/\/www.pinkgold.space\/?p=24","title":{"rendered":"OpenAI API Examples-Summarize for a 2nd grader"},"content":{"rendered":"\n<p>Open API Platform\u306eexamples\u3092node.js\u3067\u8a66\u3059\u65c5\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f<strong>Summarize for a 2nd grader<\/strong>\u3092\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30b5\u30f3\u30d7\u30eb\u306e\u30bd\u30fc\u30b9\u306f\u3053\u3061\u3089\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/examples\/default-summarize\">https:\/\/platform.openai.com\/examples\/default-summarize<\/a><\/p>\n\n\n\n<p>\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u306e\u307e\u307e\u3060\u3068\u52d5\u304b\u306a\u3044\u306e\u3067\u5c11\u3057\u4fee\u6b63\u3092\u52a0\u3048\u307e\u3059\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;user@somewhere stub]$ cat  examples_summarize.js \nrequire('dotenv').config(); \nconst { Configuration, OpenAIApi } = require(\"openai\");\n\nconst configuration = new Configuration({\n  apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nasync function run(){\n    const response = await openai.createCompletion({\n    model: \"text-davinci-003\",\n prompt: \"Explain this joke to a second-grade student:\\n\\nWhy don't we ever tell secrets on the beach?\\n\\nBecause the waves might spill the beans!\",\n    temperature: 1,\n    max_tokens: 64,\n    top_p: 1.0,\n    frequency_penalty: 0.0,\n    presence_penalty: 0.0,\n    });\n\n    if (response.data &amp;&amp; response.data.choices &amp;&amp; response.data.choices.length &gt; 0) {\n        console.log(response.data.choices&#91;0].text);\n    } else {\n        console.log(\"No response received or empty choices.\");\n    }\n}\nrun();<\/code><\/pre>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;user@www stub]$ node examples_summarize.js \nThis joke means that when you tell secrets, you should be careful. If you tell a secret on the beach, someone might overhear it, just like the waves might carry the secret away.<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Open API Platform\u306eexamples\u3092node.js\u3067\u8a66\u3059\u65c5\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306fSummarize for a 2nd grader\u3092\u8a66\u3057\u3066\u307f\u307e\u3059\u3002 \u30b5\u30f3\u30d7\u30eb\u306e\u30bd\u30fc\u30b9\u306f\u3053\u3061\u3089\u306b\u3042\u308a\u307e\u3059\u3002 https:\/\/p &#8230; <a title=\"OpenAI API Examples-Summarize for a 2nd grader\" class=\"read-more\" href=\"https:\/\/www.pinkgold.space\/?p=24\" aria-label=\"Read more about OpenAI API Examples-Summarize for a 2nd grader\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-openapi"],"_links":{"self":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/24"}],"collection":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24"}],"version-history":[{"count":4,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/24\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}