{"id":20,"date":"2023-11-03T01:28:02","date_gmt":"2023-11-03T01:28:02","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/valdemar\/?p=20"},"modified":"2023-11-03T03:09:26","modified_gmt":"2023-11-03T03:09:26","slug":"experimenting-with-github-copilot","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/valdemar\/2023\/11\/03\/experimenting-with-github-copilot\/","title":{"rendered":"Experimenting with GitHub Copilot"},"content":{"rendered":"\n<p>Since this is my first post since before projects were selected, it would be good to get readers up to speed.<\/p>\n\n\n\n<p>I did get placed with the two team members I coordinated with before class (in addition to three others) and we got our first choice project: <a href=\"https:\/\/eecs.engineering.oregonstate.edu\/capstone\/submission\/pages\/viewSingleProject.php?id=la5erT4bZG84u8l3\">SaaS Application for Fire Department 911 Risk Analysis<\/a> for our sponsor, <a href=\"https:\/\/www.levrum.com\/\">Levrum Data Technologies<\/a>.<\/p>\n\n\n\n<p>The application calculates and visualizes response times for networks of fire stations.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"947\" height=\"545\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-191550.png\" alt=\"\" class=\"wp-image-21\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-191550.png 947w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-191550-300x173.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-191550-768x442.png 768w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><figcaption class=\"wp-element-caption\">A detail of the existing UI showing the fire station response time map visualization for Corvallis, Oregon; credit: Levrum Data Technologies<\/figcaption><\/figure>\n\n\n\n<p>This is a continuation of an existing OSU project. A prototype of the server and browser-based front end already exist. Our team is continuing that work by implementing a database and a control-plane. There are a few issues with that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Only one member of our team has prior experience with .NET &amp; C#<\/li>\n\n\n\n<li>The existing code is very well modularized but that means it&#8217;s very interconnected<\/li>\n\n\n\n<li>The existing code is minimally commented<\/li>\n\n\n\n<li>There is very little external documentation<\/li>\n<\/ul>\n\n\n\n<p>In order to understand and document the code, we&#8217;ve employed traditional tools like auto-generated code maps. <em><strong>I&#8217;ve also experimented with <a href=\"https:\/\/github.com\/features\/copilot\">GitHub Copilot<\/a> to attempt to speed up the process.<\/strong><\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Here are my findings:<\/h3>\n\n\n\n<p>People who have spent much time interacting with Large Language Models (LLMs) and generative AI will point out that it&#8217;s sometimes necessary to change the wording of requests to get what you want (especially if you&#8217;re trying to bypass security features with a prompt injection).<\/p>\n\n\n\n<p>This remains true with GitHub Copilot. But, for certain functions, the precise details of the prompts are invisible to the user. You have to experiment with canned choices by selecting varying lengths and sections of code.<\/p>\n\n\n\n<p>When highlighting a class method and selecting &#8220;Explain the selected code,&#8221; I&#8217;ve found the generated text is generally accurate but not necessarily easier to understand than the code itself. It doesn&#8217;t reach outside the highlighted code for context. It will tell you about an argument and its type but it won&#8217;t explain what else in the code base might call the method and pass the argument.<\/p>\n\n\n\n<p>In fact, when I tried to use the chat to prompt Copilot to do so, I was informed it does not have access to the file structure. Of course that makes sense; the LLM isn&#8217;t on my workstation.<\/p>\n\n\n\n<p>However, highlighting a larger block, like a class with multiple methods, is much more useful. Copilot will provide a formatted breakdown of the class.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"414\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192033.png\" alt=\"\" class=\"wp-image-22\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192033.png 605w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192033-300x205.png 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><figcaption class=\"wp-element-caption\">A partial example of an explanation of a C# class generated by GitHub Copilot; credit Microsoft<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>It even provides a helpful prompt suggestion:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192255.png\" alt=\"\" class=\"wp-image-25\" width=\"616\" height=\"88\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192255.png 616w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192255-300x43.png 300w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><figcaption class=\"wp-element-caption\">Copilot suggestion to define the Strategy design pattern; credit Microsoft<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>There&#8217;s also a plugin for Visual Studio Code only called <a href=\"https:\/\/githubnext.com\/projects\/copilot-labs\/\">GitHub Copilot Labs<\/a>. It&#8217;s for experimental Copilot features and that&#8217;s apparent when you use it.<\/p>\n\n\n\n<p>The options look promising and helpful:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"196\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-200446.png\" alt=\"\" class=\"wp-image-23\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-200446.png 497w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-200446-300x118.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><figcaption class=\"wp-element-caption\">Code modification options provided by the GitHub Copilot Labs plugin ; credit Microsoft<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In practice, you can get different, usually broken results every time you try one. Below is an example of the automatic documentation. Not only did it repeat the same two lines 10 times, it provided an incorrect definition of coverage and broke the code by duplicating the class definition line.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"606\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192547.png\" alt=\"\" class=\"wp-image-24\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192547.png 589w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/7161\/files\/2023\/11\/Screenshot-2023-11-02-192547-292x300.png 292w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><figcaption class=\"wp-element-caption\">Copilot Labs automatic documentation may create good comments or it may do this; credit Levrum<\/figcaption><\/figure>\n\n\n\n<p>So, Labs is experimental, as advertised. It may be interesting to play with but it&#8217;s not a tool to use for development.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusions<\/h3>\n\n\n\n<p>I haven&#8217;t had a chance to try the main attraction: pair coding with Copilot. From what I&#8217;ve read, it&#8217;s useful except when it&#8217;s not.<\/p>\n\n\n\n<p>The basic functions of GitHub Copilot are quite useful once you understand how they  are best employed. There&#8217;s just a very slight learning curve. The Labs functions may be useful in the future if they ever work.<\/p>\n\n\n\n<p>It&#8217;s important to realize that LLMs don&#8217;t <em>understand <\/em>anything. They&#8217;re statistical inference engines. They can help speed things up a lot but you always have to check their work. To be fair, that&#8217;s also true of people. Hopefully not the understanding part, in most cases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since this is my first post since before projects were selected, it would be good to get readers up to speed. I did get placed with the two team members I coordinated with before class (in addition to three others) and we got our first choice project: SaaS Application for Fire Department 911 Risk Analysis &hellip; <a href=\"https:\/\/blogs.oregonstate.edu\/valdemar\/2023\/11\/03\/experimenting-with-github-copilot\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Experimenting with GitHub Copilot<\/span><\/a><\/p>\n","protected":false},"author":13672,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,9,6],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-github-copilot","tag-llm","tag-saas"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/users\/13672"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":4,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/posts\/20\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/valdemar\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}