Skip Navigation

Some Examples of Using GitHub Copilot

If you are like me, and you didn't immediately understand why people rave about Copilot, these simple examples by Simon Willison may be useful to you:

5
5 comments
  • I just started using it a week ago and I canโ€™t stop geeking out over it!

    My favourite is that it even writes comments well which is the thing most programmers hate the most!

    • The biggest aha-moment with Copilot for me was when I wanted to implement tools for my GPT-based personal assistant. The function calling wasn't yet available in the OpenAI API, and I've found that GPT-3.5 was really bad at using tools consistently in a long chat conversation. So I decided to implement a classifier DAG, with either a simple LLM prompt or a regular function in its nodes. Something like this:

      what is this? (reminder | todo | other)
          reminder -> what kind of reminder? (one-time | recurring)
              one-time -> return the ISO timestamp and the reminder text in a JSON object like this
              recurring -> return the cron expression and the reminder text in a JSON object like this
          todo -> what kind of todo operation (add | delete | ...)
              ...
          other -> just respond normally
      

      I wrote an example of using this classifier graph in code, something like this (it's missing a lot of important details):

      const decisionTree = new Decision(
        userIntentClassifier, {
          "REMINDER": new Decision(
            reminderClassifier, {
              "ONE_TIME": new Sequence(
                parseNaturalLanguageTime,
                createOneTimeReminder,
                explainAction
              ),
              "RECURRING": new Sequence(
                createRecurringReminder,
                explainAction
              ),
            }
          ),
          "TASK": new Decision(
            taskClassifier, {
              ...
            }
          ),
          "NONE": answerInChat,
        }
      );
      
      decisionTree.call(context);
      

      And then I started writing class Decision, class Sequence, etc. and it implemented the classes perfectly!