<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ChatGPT - さらるんねっと</title>
	<atom:link href="https://sararun.net/tag/chatgpt/feed/" rel="self" type="application/rss+xml" />
	<link>https://sararun.net</link>
	<description>経験・問題解決・趣味の成果を伝える雑記ブログ</description>
	<lastBuildDate>Thu, 18 Jan 2024 15:45:25 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://sararun.net/wp-content/uploads/2020/09/原画_自画像-100x100.png</url>
	<title>ChatGPT - さらるんねっと</title>
	<link>https://sararun.net</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>【自分語り】ChatGPTでプログラムを作る場合は雛形優先で考える方が良い</title>
		<link>https://sararun.net/chatgpt-programming-template/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chatgpt-programming-template</link>
		
		<dc:creator><![CDATA[sararu]]></dc:creator>
		<pubDate>Thu, 18 Jan 2024 15:40:49 +0000</pubDate>
				<category><![CDATA[IT・情報]]></category>
		<category><![CDATA[自分のこと]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[解説]]></category>
		<guid isPermaLink="false">https://sararun.net/?p=10693</guid>

					<description><![CDATA[<p>AIを使ってプログラミングする場合、技術を存分に活かしている人ならGithub Copilotを利用していると思うが、月々課金があるので躊躇してChatGPT(以下、GPTくんと呼ぶ)を使い続けている人がいるかもしれない [&#8230;]</p>
<p>The post <a href="https://sararun.net/chatgpt-programming-template/">【自分語り】ChatGPTでプログラムを作る場合は雛形優先で考える方が良い</a> first appeared on <a href="https://sararun.net">さらるんねっと</a>.</p>]]></description>
										<content:encoded><![CDATA[<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6168783384676131"
     crossorigin="anonymous"></script>
<!-- レスポンシブ：記事内_見出し上_横長タイプ -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6168783384676131"
     data-ad-slot="9012101888"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p>AIを使ってプログラミングする場合、技術を存分に活かしている人ならGithub Copilotを利用していると思うが、月々課金があるので躊躇してChatGPT(以下、GPTくんと呼ぶ)を使い続けている人がいるかもしれない。<br>私のことである。</p>



<p>GPTくんで作成したいプログラムの内容を伝えればGPTくんがプログラムを提案してくれるのだが、誤った指示だと予期せぬ結果が返ってくることがある。</p>



<p>それを回避するために、私が日々気をつけていることをまとめた。</p>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6168783384676131"
     crossorigin="anonymous"></script>
<!-- レスポンシブ：記事内_見出し上_横長タイプ_2 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6168783384676131"
     data-ad-slot="1914976963"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p>私が指示で必ず気をつけていることは以下のとおり。</p>



<p>・5W1Hで書く。<br>・環境を書く。<br>・実装したい要点は箇条書きで書く。</p>



<p>5W1Hは全部書かなくても良いが、これを意識してGPTくんに指示すると、自分がすでに知っているような情報は省略されてスマートな回答が返ってくるのでおすすめする。<br>「WHO：だれが」「Why：なぜ」は重要ではないので考えなくても良いが、「When：いつ」「Where：どこで」「What：何を」は必ず書くべき。<br>特に、「When：いつ」「Where：どこで」はプログラムではif文やfor文の挿入位置等を考えなければならないので、これをGPTくんに正しく指示することが必要だ。<br>ただし、5W1Hは作成したいプログラムを頭の中で描けている前提で指示をしなければならない。<br>「When：いつ」「Where：どこで」の表現をミスすると思っていたプログラムとは異なる処理になっていることがある。</p>



<p>環境については簡単だ。<br>たとえば、SQL文の作成についてRDBはPostgreSQLを使っているならなら「PostgreSQL」と書かなければならないし、webアプリ開発でjavascriptライブラリ「React」で書いているなら「React」を使用していることを書く。さらには「非同期通信でjavaのサーブレットにリクエストしたい」と書けばjavaで動作していることを理解してくれて、クライアントとサーバー両方のプログラムを同時に作成してくれる。開発をはじめたばかりならマッピングの設定(web.xml)も勝手に用意してくれる。<br>（クライアント・サーバー両方の指示は長文回答になりやすいので注意）<br>環境を指示しないと、対応していないプログラムが作成されて再度指示を出す必要があるので、環境を先に指示することが大事だ。<br>ただし、ここでも注意が必要で、長期的に質問をしているとあるタイミングで指示した環境とは異なる表現になっていることがある。<br>（例：javascriptライブラリを使用しているのに別のライブラリやライブラリを使用しないプログラムになっている）<br>結局、自分が知っているプログラムを前提に指示していないとGPTくんの回答の誤りに気づけないので注意したい。</p>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6168783384676131"
     crossorigin="anonymous"></script>
<!-- レスポンシブ：記事内_見出し上_横長タイプ_3 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6168783384676131"
     data-ad-slot="7852903197"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p>実装したい要点は箇条書きで書くことは自分もGPTくんも理解しやすい形にするための書き方だ。<br>たとえば、webアプリで以下のようなページ(表示)があるとする。</p>



<figure class="wp-block-image aligncenter size-full"><img fetchpriority="high" decoding="async" width="435" height="161" src="https://sararun.net/wp-content/uploads/2024/01/image-30.png" alt="" class="wp-image-10746" srcset="https://sararun.net/wp-content/uploads/2024/01/image-30.png 435w, https://sararun.net/wp-content/uploads/2024/01/image-30-300x111.png 300w" sizes="(max-width: 435px) 100vw, 435px" /></figure>



<p>入力フォームに文字列を入れて、すべてが半角英数だったらTrue、1文字でも半角英数ではなかった場合はFalseを入力フォームの下に表示するという動作とする。</p>



<p>これをGPTくんに指示する場合、以下のように書く。</p>



<p>・入力フォーム1つとボタン1つがある。<br>・ボタンの名前は「チェック」<br>・ボタンを押すと入力フォームの文字列を取得して、1文字ずつ検査をする<br>・すべての文字列が半角英数なら「True」、それ以外なら「False」を取得して、入力フォームの下に表示する</p>



<p>上記の箇条書きを実際にGPTに指示すると、以下の回答が返ってきた。<br>※事前にwebアプリの環境を伝えた。（jQuery）</p>



<pre class="wp-block-code html has-small-font-size"><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;文字列検査ページ&lt;/title&gt;
    &lt;script src="https://code.jquery.com/jquery-3.6.4.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

    &lt;h2&gt;文字列検査ページ&lt;/h2&gt;

    &lt;label for="inputText"&gt;入力フォーム:&lt;/label&gt;
    &lt;input type="text" id="inputText"&gt;
    &lt;button id="checkButton"&gt;チェック&lt;/button&gt;

    &lt;div id="result"&gt;&lt;/div&gt;

    &lt;script&gt;
        $(document).ready(function () {
            // チェックボタンがクリックされた時の処理
            $("#checkButton").click(function () {
                // 入力フォームの文字列を取得
                var inputString = $("#inputText").val();

                // 文字列が空でない場合に検査を行う
                if (inputString.trim() !== "") {
                    // 半角英数の正規表現パターン
                    var pattern = /^&#91;a-zA-Z0-9]+$/;

                    // 全ての文字が半角英数かどうかを検査
                    if (pattern.test(inputString)) {
                        // 結果を表示
                        $("#result").text("True");
                    } else {
                        $("#result").text("False");
                    }
                } else {
                    // 入力フォームが空の場合の処理
                    $("#result").text("入力フォームが空です。");
                }
            });
        });
    &lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>



<p>この記事では「雛形優先で考える」のテーマなので、自分が想像していた動的処理と正確に一致しているかは省略させていただくが、少なくとも私がほしかったプログラムになっていたので、箇条書きで書くということは手順を明確にして指示するので理想的な回答が返ってくることが分かる。</p>



<p>もし、あなたが考えたプログラムとは異なっている場合、指示内容がかけている可能性が十分ある。</p>



<p>先ほどのプログラムは私が欲しかったプログラムではあったものの、ページタイトルは指示していなかったのでGPTくんが勝手に「文字列検査ページ」と命名した。つまり指示不足。あとは文字列チェックを正規表現にするかの指定もしなかったので勝手に正規表現パターンでプログラムを書いてくれた。</p>



<p>このように指示が少しでも欠けているとGPTが配慮して定義することがあるので注意したい。</p>



<p>なお、「※事前にwebアプリの環境を伝えた。（jQuery）」は以下のような質問をしただけである。</p>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="686" height="510" src="https://sararun.net/wp-content/uploads/2024/01/image-29.png" alt="" class="wp-image-10734" srcset="https://sararun.net/wp-content/uploads/2024/01/image-29.png 686w, https://sararun.net/wp-content/uploads/2024/01/image-29-300x223.png 300w" sizes="(max-width: 686px) 100vw, 686px" /><figcaption class="wp-element-caption">今回は簡略化したので本来は複数の条件を書くべき。</figcaption></figure>



<p>以上の解説から、GPTくんでプログラムを作成する場合はあくまで雛形プログラムを用意してもらうために指示することを意識してもらいたい。</p>



<p>あなたが考えたプログラムをGPTに貼り付けて、気をつけるべきことを意識して改修点を指示をすれば理想的なプログラムを作ることも可能だ。</p>



<p>しかし、長期的に質問をしていると誤った回答になることもあり、自分自身がプログラムを理解していないとバグに至ってしまうので、やはり基礎的なプログラムは事前に理解・学習するべきだと思う。</p>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6168783384676131"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-6168783384676131"
     data-ad-slot="6070441179"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
		<div class="wpulike wpulike-default " ><div class="wp_ulike_general_class wp_ulike_is_restricted"><button type="button"
					aria-label="いいねボタン"
					data-ulike-id="10693"
					data-ulike-nonce="234c3872f2"
					data-ulike-type="post"
					data-ulike-template="wpulike-default"
					data-ulike-display-likers=""
					data-ulike-likers-style="popover"
					class="wp_ulike_btn wp_ulike_put_image wp_post_btn_10693"></button><span class="count-box wp_ulike_counter_up" data-ulike-counter-value="0"></span>			</div></div>
	<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_line" href="https://www.addtoany.com/add_to/line?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Line" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_threads" href="https://www.addtoany.com/add_to/threads?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Threads" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_instapaper" href="https://www.addtoany.com/add_to/instapaper?linkurl=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&amp;linkname=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" title="Instapaper" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fsararun.net%2Fchatgpt-programming-template%2F&#038;title=%E3%80%90%E8%87%AA%E5%88%86%E8%AA%9E%E3%82%8A%E3%80%91ChatGPT%E3%81%A7%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E4%BD%9C%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E9%9B%9B%E5%BD%A2%E5%84%AA%E5%85%88%E3%81%A7%E8%80%83%E3%81%88%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84" data-a2a-url="https://sararun.net/chatgpt-programming-template/" data-a2a-title="【自分語り】ChatGPTでプログラムを作る場合は雛形優先で考える方が良い"></a></p><p>The post <a href="https://sararun.net/chatgpt-programming-template/">【自分語り】ChatGPTでプログラムを作る場合は雛形優先で考える方が良い</a> first appeared on <a href="https://sararun.net">さらるんねっと</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
