{"id":9,"date":"2023-07-05T19:15:06","date_gmt":"2023-07-05T10:15:06","guid":{"rendered":"https:\/\/www.pinkgold.space\/?p=9"},"modified":"2024-09-23T17:16:19","modified_gmt":"2024-09-23T08:16:19","slug":"openai-platform-examples-qa","status":"publish","type":"post","link":"https:\/\/www.pinkgold.space\/?p=9","title":{"rendered":"OpenAI API Examples-Q&#038;A"},"content":{"rendered":"\n<p>ChatGPT\u306eAPI\u3092\u697d\u3057\u3080\u70ba\u306b\u8ab2\u91d1\u3092\u3055\u308c\u305f\u65b9\u306f\u591a\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u307e\u305f\u306f\u5371\u6a5f\u611f\u304c\u304d\u3063\u304b\u3051\u3068\u306a\u308a\u5b66\u3073\u306e\u305f\u3081\u306b\u8ab2\u91d1\u3055\u308c\u308b\u65b9\u3082\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3069\u306e\u307f\u3061\u8ab2\u91d1\u3092\u3057\u305f\u3089\u4f7f\u308f\u306a\u3044\u3068\u3082\u3063\u305f\u3044\u306a\u3044\u306e\u3067\u4f8b\u6587\u304f\u3089\u3044\u306f\u8a66\u3057\u3066\u697d\u3057\u3093\u3067\u304a\u304d\u305f\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u306fExamples\u306e\u6700\u521d\u306b\u3042\u308bQ&amp;A\u306b\u3064\u3044\u3066\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/examples\/default-qa\">https:\/\/platform.openai.com\/examples\/default-qa<\/a>  \u3067node.js\u3092\u9078\u629e\u3059\u308b\u3068\u30b5\u30f3\u30d7\u30eb\u306e\u30b3\u30fc\u30c9\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const { Configuration, OpenAIApi } = require(\"openai\");\n\nconst configuration = new Configuration({\n  apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\n\nconst response = await openai.createCompletion({\n  model: \"text-davinci-003\",\n  prompt: \"I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \\\"Unknown\\\".\\n\\nQ: What is human life expectancy in the United States?\\nA: Human life expectancy in the United States is 78 years.\\n\\nQ: Who was president of the United States in 1955?\\nA: Dwight D. Eisenhower was president of the United States in 1955.\\n\\nQ: Which party did he belong to?\\nA: He belonged to the Republican Party.\\n\\nQ: What is the square root of banana?\\nA: Unknown\\n\\nQ: How does a telescope work?\\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\\n\\nQ: Where were the 1992 Olympics held?\\nA: The 1992 Olympics were held in Barcelona, Spain.\\n\\nQ: How many squigs are in a bonk?\\nA: Unknown\\n\\nQ: Where is the Valley of Kings?\\nA:\",\n  temperature: 0,\n  max_tokens: 100,\n  top_p: 1,\n  frequency_penalty: 0.0,\n  presence_penalty: 0.0,\n  stop: &#91;\"\\n\"],\n});<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u3053\u306e\u307e\u307e\u30b3\u30d4\u30da\u3057\u3066\u3082\u52d5\u304d\u307e\u305b\u3093\u3002<\/h2>\n\n\n\n<p>OpenAI\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306e\u4f8b\u6587\u306f\u4e00\u822c\u7684\u306a\u4f7f\u7528\u4f8b\u3092\u793a\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3042\u308a\u3001\u5b8c\u5168\u306a\u52d5\u4f5c\u3092\u4fdd\u8a3c\u3059\u308b\u3082\u306e\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u4f8b\u6587\u3092\u305d\u306e\u307e\u307e\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u52d5\u4f5c\u3057\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u306f\u3001\u4f8b\u6587\u304c\u7279\u5b9a\u306e\u8981\u4ef6\u3084\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b\u304b\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3084\u5909\u66f4\u306b\u8ffd\u968f\u3057\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u6b63\u5e38\u306b\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u306b\u306f\u3001\u9069\u5207\u306aAPI\u547c\u3073\u51fa\u3057\u3068\u30c7\u30fc\u30bf\u51e6\u7406\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u3001API\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5f62\u5f0f\u3001\u5fc5\u8981\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3001\u304a\u3088\u3073\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u89e3\u91c8\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u52d5\u4f5c\u74b0\u5883\u3092\u4f5c\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4e8b\u524d\u6e96\u5099\u3068\u3057\u3066node.js\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<a href=\"https:\/\/nodejs.org\/ja\" data-type=\"URL\" data-id=\"https:\/\/nodejs.org\/ja\">\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\u304b\u3089LTS\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306fv18.16.0\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>package.json\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002\u4f5c\u6210\u3057\u305f\u3089npm install\u3067\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;user@somewhere stub]$ cat package.json\n{\n  \"dependencies\": {\n    \"dotenv\": \"^16.3.1\",\n    \"openai\": \"^3.3.0\"\n  }\n}\n&#91;user@somewhere stub]$ npm install<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u52d5\u304f\u3088\u3046\u306b\u4fee\u6b63\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/h2>\n\n\n\n<p>\u4e8b\u524d\u6e96\u5099\u3068\u3057\u3066.env\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u767b\u9332\u3057\u305fAPI\u306e\u30c8\u30fc\u30af\u30f3\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;user@somewhrere stub]$ cat .env\nOPENAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx<\/code><\/pre>\n\n\n\n<p>\u65e9\u901f\u5b9f\u88c5\u3057\u3066\u3044\u304d\u307e\u3059\u3002API\u30ad\u30fc\u3092\u8aad\u307f\u8fbc\u3093\u3067\u51e6\u7406\u306e\u90e8\u5206\u3092\u95a2\u6570\u306b\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>require('dotenv').config();  \/\/ dotenv\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nconst { Configuration, OpenAIApi } = require(\"openai\");\n\nconst configuration = new Configuration({\n  apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\n\nasync function run(){\n    const response = await openai.createCompletion({\n        model: \"text-davinci-003\",\n       prompt: \"I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \\\"Unknown\\\".\\n\\nQ: What is human life expectancy in the United States?\\nA: Human life expectancy in the United States is 78 years.\\n\\nQ: Who was president of the United States in 1955?\\nA: Dwight D. Eisenhower was president of the United States in 1955.\\n\\nQ: Which party did he belong to?\\nA: He belonged to the Republican Party.\\n\\nQ: What is the square root of banana?\\nA: Unknown\\n\\nQ: How does a telescope work?\\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\\n\\nQ: Where were the 1992 Olympics held?\\nA: The 1992 Olympics were held in Barcelona, Spain.\\n\\nQ: How many squigs are in a bonk?\\nA: Unknown\\n\\nQ: Where is the Valley of Kings?\\nA:\",\n        temperature: 0,\n        max_tokens: 100,\n        top_p: 1,\n        frequency_penalty: 0.0,\n        presence_penalty: 0.0,\n        stop: &#91;\"\\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}\n<\/code><\/pre>\n\n\n\n<p>\u5b9f\u884c\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u7d50\u679c\u3092\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n&#91;user@somewhere stub]$ node qa.js\n The Valley of Kings is located in Luxor, Egypt.<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-left\">\u305d\u308c\u3067\u306f\u6df1\u5800\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">createCompletion\u95a2\u6570\u306b\u6e21\u3057\u3066\u3044\u308b\u5f15\u6570\u304b\u3089\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u306fmodel: &#8220;text-davinci-003&#8221;,\u306e\u90e8\u5206\u3067\u3059\u3002chatGPT\u306b\u306f\u8907\u6570\u306e\u30e2\u30c7\u30eb\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u306eOverView\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>URL\u306f<a href=\"https:\/\/platform.openai.com\/docs\/models\/overview\">https:\/\/platform.openai.com\/docs\/models\/overview<\/a>\u3067\u3059\u3002<a href=\"https:\/\/platform.openai.com\/docs\/models\/overview\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/platform.openai.com\/docs\/models\/overview\">Overview<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>MODELS<\/th><th>DESCRIPTION<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/gpt-4\">GPT-4<\/a><\/td><td>A set of models that improve on GPT-3.5 and can understand as well as generate natural language or code<br>GPT-3.5\u3092\u6539\u826f\u3057\u3001\u81ea\u7136\u8a00\u8a9e\u3084\u30b3\u30fc\u30c9\u3092\u7406\u89e3\u30fb\u751f\u6210\u3067\u304d\u308b\u30e2\u30c7\u30eb\u306e\u96c6\u5408\u3002<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/gpt-3-5\">GPT-3.5<\/a><\/td><td>A set of models that improve on GPT-3 and can understand as well as generate natural language or code<br>GPT-3 \u3092\u6539\u826f\u3057\u3001\u81ea\u7136\u8a00\u8a9e\u3084\u30b3\u30fc\u30c9\u3092\u7406\u89e3\u30fb\u751f\u6210\u3067\u304d\u308b\u30e2\u30c7\u30eb\u7fa4<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/dall-e\">DALL\u00b7E<\/a><\/td><td>A model that can generate and edit images given a natural language prompt<br>\u81ea\u7136\u8a00\u8a9e\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u4e0e\u3048\u3066\u753b\u50cf\u3092\u751f\u6210\u30fb\u7de8\u96c6\u3067\u304d\u308b\u30e2\u30c7\u30eb<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/whisper\">Whisper<\/a><\/td><td>A model that can convert audio into text<br>\u97f3\u58f0\u3092\u30c6\u30ad\u30b9\u30c8\u306b\u5909\u63db\u3067\u304d\u308b\u30e2\u30c7\u30eb<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/embeddings\">Embeddings<\/a><\/td><td>A set of models that can convert text into a numerical form<br>\u30c6\u30ad\u30b9\u30c8\u3092\u6570\u5024\u306b\u5909\u63db\u3067\u304d\u308b\u30e2\u30c7\u30eb\u306e\u30bb\u30c3\u30c8<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/moderation\">Moderation<\/a><\/td><td>A fine-tuned model that can detect whether text may be sensitive or unsafe<br>\u7e4a\u7d30\u306a\u30c6\u30ad\u30b9\u30c8\u304b\u5b89\u5168\u3067\u306a\u3044\u30c6\u30ad\u30b9\u30c8\u304b\u3092\u691c\u51fa\u3067\u304d\u308b\u3001\u5fae\u8abf\u6574\u3055\u308c\u305f\u30e2\u30c7\u30eb<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/models\/gpt-3\">GPT-3<\/a>Legacy<\/td><td>A set of models that can understand and generate natural language<br>\u81ea\u7136\u8a00\u8a9e\u3092\u7406\u89e3\u3057\u751f\u6210\u3067\u304d\u308b\u30e2\u30c7\u30eb\u306e\u30bb\u30c3\u30c8<\/td><\/tr><tr><td><a href=\"https:\/\/platform.openai.com\/docs\/deprecations\">Deprecated<\/a><\/td><td>A full list of models that have been deprecated<br>\u975e\u63a8\u5968\u3068\u306a\u3063\u305f\u30e2\u30c7\u30eb\u306e\u5168\u30ea\u30b9\u30c8<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4eca\u56de\u306e\u4f8b\u6587\u3067\u767b\u5834\u3059\u308b\u306e\u306ftext-davinci-003\u3067\u3057\u305f\u3002\u3069\u3046\u3044\u3046\u30e2\u30c7\u30eb\u306a\u306e\u304b\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002 curie, babbage, or ada\u3088\u308a\u3082\u512a\u308c\u305f\u54c1\u8cea\u3068\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u3082\u305d\u3082\u305d\u306e3\u4eba\u306e\u3053\u3068\u304c\u30d4\u30f3\u3068\u304d\u307e\u305b\u3093\u3002turbo\u304c\u3064\u3044\u3066\u3044\u308b\u30e2\u30c7\u30eb\u306f\u9032\u5316\u3092\u3064\u3065\u3051\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>LATEST MODEL<\/th><th>DESCRIPTION<\/th><th>MAX TOKENS<\/th><th>TRAINING DATA<\/th><\/tr><\/thead><tbody><tr><td>gpt-3.5-turbo<\/td><td>Most capable GPT-3.5 model and optimized for chat at 1\/10th the cost of&nbsp;<code>text-davinci-003<\/code>. Will be updated with our latest model iteration 2 weeks after it is released.<br>text-davinci-003\u306e1\/10\u306e\u30b3\u30b9\u30c8\u3067\u30c1\u30e3\u30c3\u30c8\u306b\u6700\u9069\u5316\u3055\u308c\u305fGPT-3.5\u6700\u9ad8\u6027\u80fd\u30e2\u30c7\u30eb\u3002\u6700\u65b0\u30e2\u30c7\u30eb\u306f\u767a\u58f2\u5f8c2\u9031\u9593\u3067\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002<\/td><td>4,096 tokens<\/td><td>Up to Sep 2021<\/td><\/tr><tr><td>gpt-3.5-turbo-16k<\/td><td>Same capabilities as the standard&nbsp;<code>gpt-3.5-turbo<\/code>&nbsp;model but with 4 times the context.<br>\u6a19\u6e96\u306egpt-3.5\u30bf\u30fc\u30dc\u30fb\u30e2\u30c7\u30eb\u3068\u540c\u3058\u6027\u80fd\u3060\u304c\u3001\u30b3\u30f3\u30c6\u30af\u30b9\u30c8\u306f4\u500d\u3002<\/td><td>16,384 tokens<\/td><td>Up to Sep 2021<\/td><\/tr><tr><td>gpt-3.5-turbo-0613<\/td><td>Snapshot of&nbsp;<code>gpt-3.5-turbo<\/code>&nbsp;from June 13th 2023 with function calling data. Unlike&nbsp;<code>gpt-3.5-turbo<\/code>, this model will not receive updates, and will be deprecated 3 months after a new version is released.<br>2023\u5e746\u670813\u65e5\u306egpt-3.5-turbo\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3002gpt-3.5-turbo\u3068\u306f\u7570\u306a\u308a\u3001\u3053\u306e\u30e2\u30c7\u30eb\u306f\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3092\u53d7\u3051\u305a\u3001\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u304b\u30893\u30f6\u6708\u5f8c\u306b\u975e\u63a8\u5968\u3068\u306a\u308a\u307e\u3059\u3002<\/td><td>4,096 tokens<\/td><td>Up to Sep 2021<\/td><\/tr><tr><td>gpt-3.5-turbo-16k-0613<\/td><td>Snapshot of&nbsp;<code>gpt-3.5-turbo-16k<\/code>&nbsp;from June 13th 2023. Unlike&nbsp;<code>gpt-3.5-turbo-16k<\/code>, this model will not receive updates, and will be deprecated 3 months after a new version is released.<br>2023\u5e746\u670813\u65e5\u306egpt-3.5-turbo-16k\u306e\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u3002gpt-3.5-turbo-16k\u3068\u306f\u7570\u306a\u308a\u3001\u3053\u306e\u30e2\u30c7\u30eb\u306f\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3092\u53d7\u3051\u305a\u3001\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u304b\u30893\u30f6\u6708\u5f8c\u306b\u975e\u63a8\u5968\u3068\u306a\u308a\u307e\u3059\u3002<\/td><td>16,384 tokens<\/td><td>Up to Sep 2021<\/td><\/tr><tr><td>text-davinci-003 (Legacy)<\/td><td>Can do any language task with better quality, longer output, and consistent instruction-following than the curie, babbage, or ada models. Also supports some additional features such as&nbsp;<a href=\"https:\/\/platform.openai.com\/docs\/guides\/gpt\/inserting-text\">inserting text<\/a>.<br>\u30ad\u30e5\u30ea\u30fc\u3001\u30d0\u30d9\u30c3\u30b8\u3001\u30a2\u30c0\u306e\u5404\u30e2\u30c7\u30eb\u3088\u308a\u3082\u512a\u308c\u305f\u54c1\u8cea\u3001\u9577\u3044\u51fa\u529b\u3001\u4e00\u8cab\u3057\u305f\u547d\u4ee4\u8ffd\u5f93\u6027\u3067\u3042\u3089\u3086\u308b\u8a00\u8a9e\u30bf\u30b9\u30af\u3092\u3053\u306a\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u307e\u305f\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u633f\u5165\u306a\u3069\u3001\u3044\u304f\u3064\u304b\u306e\u8ffd\u52a0\u6a5f\u80fd\u3082\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u3002<br><\/td><td>4,097 tokens<\/td><td>Up to Jun 2021<\/td><\/tr><tr><td>text-davinci-002 (Legacy)<\/td><td>Similar capabilities to&nbsp;<code>text-davinci-003<\/code>&nbsp;but trained with supervised fine-tuning instead of reinforcement learning<br>text-davinci-003\u3068\u540c\u69d8\u306e\u6a5f\u80fd\u3092\u6301\u3064\u304c\u3001\u5f37\u5316\u5b66\u7fd2\u306e\u4ee3\u308f\u308a\u306b\u6559\u5e2b\u3042\u308a\u306e\u5fae\u8abf\u6574\u3067\u5b66\u7fd2\u3055\u305b\u308b\u3002<\/td><td>4,097 tokens<\/td><td>Up to Jun 2021<\/td><\/tr><tr><td>code-davinci-002 (Legacy)<\/td><td>Optimized for code-completion tasks<br>\u30b3\u30fc\u30c9\u88dc\u5b8c\u30bf\u30b9\u30af\u306e\u6700\u9069\u5316<\/td><td>8,001 tokens<\/td><td>Up to Jun 2021<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u6b21\u306b\u7b2c\u4e8c\u5f15\u6570\u306eprompt\u3067\u3059\u304c\u3001\u8cea\u554f\u306a\u3093\u3060\u306a\u3068\u308f\u304b\u308b\u306e\u3067\u98db\u3070\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e09\u5f15\u6570\u306etemperature: 0,\u306e\u90e8\u5206\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002temperature\u3068\u306f\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u306b\u304a\u3051\u308b\u6e29\u5ea6\u306e\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<p>\u6e29\u5ea6\u306f0\u304b\u30892\u306e\u9593\u30020.8\u306e\u3088\u3046\u306a\u9ad8\u3044\u5024\u306f\u51fa\u529b\u3092\u3088\u308a\u30e9\u30f3\u30c0\u30e0\u306b\u3057\u30010.2\u306e\u3088\u3046\u306a\u4f4e\u3044\u5024\u306f\u51fa\u529b\u3092\u3088\u308a\u96c6\u4e2d\u3057\u3066\u6c7a\u5b9a\u8ad6\u7684\u306b\u3059\u308b\u3002\u3068\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3060\u3051\u3067\u3082\u3044\u308d\u3044\u308d\u697d\u3057\u3081\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>(property) CreateCompletionRequest[&#8216;temperature&#8217;]?: number | null | undefined<\/p>\n\n\n\n<p>What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or&nbsp;<code>top_p<\/code>&nbsp;but not both.<\/p>\n\n\n\n<p><em>@type<\/em>&nbsp;\u2014 {number}<\/p>\n\n\n\n<p><em>@memberof<\/em>&nbsp;\u2014 CreateCompletionRequest<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7b2c\u56db\u5f15\u6570\u306emax_tokens\u306f\u76f4\u89b3\u7684\u306b\u7406\u89e3\u3067\u304d\u308b\u306e\u3067\u98db\u3070\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e94\u5f15\u6570\u306e top_p: 1\u306b\u3064\u3044\u3066\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n\n\n\n<p>\u300c\u6838\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u3068\u547c\u3070\u308c\u308b\u3001\u6e29\u5ea6\u306b\u3088\u308b\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u306b\u4ee3\u308f\u308b\u3082\u306e\u3067\u3001top_p \u306e\u78ba\u7387\u8cea\u91cf\u3092\u6301\u3064\u30c8\u30fc\u30af\u30f3\u306e\u7d50\u679c\u3092\u8003\u616e\u3059\u308b\u30e2\u30c7\u30eb\u3067\u3059\u3002\u3064\u307e\u308a\u30010.1\u306f\u4e0a\u4f4d10%\u306e\u78ba\u7387\u3092\u69cb\u6210\u3059\u308b\u30c8\u30fc\u30af\u30f3\u306e\u307f\u304c\u8003\u616e\u3055\u308c\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002\u4e00\u822c\u7684\u306b\u306f\u3001\u3053\u308c\u304b\u6e29\u5ea6\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3092\u63a8\u5968\u3057\u307e\u3059\u304c\u3001\u4e21\u65b9\u306f\u63a8\u5968\u3057\u307e\u305b\u3093\u3002\u300d<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>(property) CreateCompletionRequest[&#8216;top_p&#8217;]?: number | null | undefined<br>An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.<\/p>\n\n\n\n<p>@type \u2014 {number}<\/p>\n\n\n\n<p>@memberof \u2014 CreateCompletionRequest<\/p>\n<\/blockquote>\n\n\n\n<p>\u3053\u3053\u3067\u78ba\u7387\u8cea\u91cf\u3068\u3044\u3046\u7528\u8a9e\u304c\u3067\u3066\u304d\u307e\u3059\u3002\u78ba\u7387\u8cea\u91cf\u95a2\u6570\u306b\u3064\u3044\u3066\u304b\u307f\u7815\u3044\u3066\u77e5\u308a\u305f\u3044\u65b9\u306f<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.youtube.com\/watch?v=bTFMsKqWLAs\" data-type=\"URL\" data-id=\"https:\/\/www.youtube.com\/watch?v=bTFMsKqWLAs\" target=\"_blank\">\u99c6\u3051\u51fa\u3057\u30a8\u30f3\u30b8\u30cb\u30a2\u3055\u3093\u306e\u52d5\u753b<\/a>\u304c\u53c2\u8003\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7b2c\u516d\u5f15\u6570\u306efrequency_penalty: 0.0\u306b\u3064\u3044\u3066\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model&#8217;s likelihood to repeat the same line verbatim.&nbsp;<a href=\"vscode-file:\/\/vscode-app\/c:\/Users\/ckklu\/AppData\/Local\/Programs\/Microsoft%20VS%20Code\/resources\/app\/out\/vs\/code\/electron-sandbox\/workbench\/workbench.html\">See more information about frequency and presence penalties.<\/a><\/p>\n\n\n\n<p><em>@type<\/em>&nbsp;\u2014 {number}<\/p>\n\n\n\n<p><em>@memberof<\/em>&nbsp;\u2014 CreateCompletionRequest<\/p>\n<\/blockquote>\n\n\n\n<p>2.0\u304b\u30892.0\u306e\u9593\u306e\u6570\u5024\u3002\u6b63\u306e\u5024\u306f\u3001\u65b0\u3057\u3044\u30c8\u30fc\u30af\u30f3\u306b\u3001\u3053\u308c\u307e\u3067\u306e\u30c6\u30ad\u30b9\u30c8\u306b\u304a\u3051\u308b\u65e2\u5b58\u306e\u983b\u5ea6\u306b\u57fa\u3065\u3044\u3066\u30da\u30ca\u30eb\u30c6\u30a3\u3092\u4e0e\u3048\u3001\u30e2\u30c7\u30eb\u304c\u540c\u3058\u884c\u3092\u9010\u8a9e\u7684\u306b\u7e70\u308a\u8fd4\u3059\u53ef\u80fd\u6027\u3092\u6e1b\u3089\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e03\u5f15\u6570\u306epresence_penalty: 0.0\u306b\u3064\u3044\u3066\u3082\u540c\u69d8\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model&#8217;s likelihood to talk about new topics.&nbsp;<a href=\"vscode-file:\/\/vscode-app\/c:\/Users\/ckklu\/AppData\/Local\/Programs\/Microsoft%20VS%20Code\/resources\/app\/out\/vs\/code\/electron-sandbox\/workbench\/workbench.html\">See more information about frequency and presence penalties.<\/a><\/p>\n\n\n\n<p><em>@type<\/em>&nbsp;\u2014 {number}<\/p>\n\n\n\n<p><em>@memberof<\/em>&nbsp;\u2014 CreateCompletionRequest<\/p>\n<\/blockquote>\n\n\n\n<p>\u4e00\u756a\u6700\u5f8c\u306e\u7b2c8\u5f15\u6570 stop: [&#8220;\\n&#8221;]\u306e\u90e8\u5206\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u5358\u7d14\u306b\u8cea\u554f\u306f\u3053\u3053\u307e\u3067\u3060\u3088\u3068\u3001\u533a\u5207\u308a\u6587\u5b57\u3092\u4f1d\u3048\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u6700\u5f8c\u306b<\/p>\n\n\n\n<p>\u4f8b\u6587\u4ee5\u5916\u306b\u3082\u5f15\u6570\u304c\u3042\u308b\u306e\u3067\u516c\u5f0f\u30b5\u30a4\u30c8\u306eAPI\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u3088\u304f\u8aad\u3093\u3067\u7406\u89e3\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/completions\">https:\/\/platform.openai.com\/docs\/api-reference\/completions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ChatGPT\u306eAPI\u3092\u697d\u3057\u3080\u70ba\u306b\u8ab2\u91d1\u3092\u3055\u308c\u305f\u65b9\u306f\u591a\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u307e\u305f\u306f\u5371\u6a5f\u611f\u304c\u304d\u3063\u304b\u3051\u3068\u306a\u308a\u5b66\u3073\u306e\u305f\u3081\u306b\u8ab2\u91d1\u3055\u308c\u308b\u65b9\u3082\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3069\u306e\u307f\u3061\u8ab2\u91d1\u3092\u3057\u305f\u3089\u4f7f\u308f\u306a\u3044\u3068\u3082\u3063\u305f\u3044\u306a\u3044\u306e\u3067\u4f8b\u6587\u304f\u3089\u3044\u306f\u8a66\u3057\u3066\u697d\u3057 &#8230; <a title=\"OpenAI API Examples-Q&#038;A\" class=\"read-more\" href=\"https:\/\/www.pinkgold.space\/?p=9\" aria-label=\"Read more about OpenAI API Examples-Q&#038;A\">\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-9","post","type-post","status-publish","format-standard","hentry","category-openapi"],"_links":{"self":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/9"}],"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=9"}],"version-history":[{"count":8,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":31,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions\/31"}],"wp:attachment":[{"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pinkgold.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}