Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OCX / EclipseCon 2024: GitHub Copilot + Spring:...

OCX / EclipseCon 2024: GitHub Copilot + Spring: Making AI-Assisted Coding Spring Aware

Martin Lippert

October 24, 2024
Tweet

More Decks by Martin Lippert

Other Decks in Technology

Transcript

  1. Jinbo Wang, Senior Software Engineer, Microsoft Martin Lippert, Spring Engineering,

    Broadcom October 2024 GitHub Copilot + Spring: Making AI-assisted Coding Spring aware Copyright © 2024 Broadcom, Inc. or its affiliates.
  2. Refactor Code in a Specific Pattern - Replace ‘+’, ‘StringBuffer’

    to ‘StringBuilder’, ‘Text Block’ - Escape String - Dedup repeated code - Migrate to design patterns (Builder, Singleton, etc.) - Extract long method to smaller ones …
  3. Code Migration: Modernize Legacy Code - Text Block for Multiline

    Strings - Replace Loop with Streams API - Use Enhanced Switch Expressions - Use Pattern Matching for instance of
  4. IDE Refactoring vs AI Refactoring ► IDE Refactoring - Rule-based,

    Predefined - Limited by IDE features - Requires developers to understand when and how to use it ► AI Refactoring - Trained on huge amounts of examples, easy to scale - More creative, can handle more complex refactoring pattern - Suggest refactoring the developer might not have considered
  5. In general, there are two ways Influence the AI assistant

    Changing the model itself (e.g. via fine tuning) Feeding additional information when asking (e.g. better prompts/questions, RAG, etc.)
  6. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information
  7. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM
  8. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response
  9. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response
  10. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project
  11. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project
  12. APIs for Copilot There are APIs in place within VSCode

    to interact with Copilot: - API to submit prompts to the LLM yourself (direct use of Copilot LLM) - API to enhance Copilot Chat (open ended questions) - Enhance / change the prompt - Specify tasks - Fill in variables / placeholders - Enhance / modify the result (e.g. insert buttons) - Inline Chats: no extension API available yet - Side note: APIs are still evolving rapidly, moving target
  13. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Predefine the question, no need for the user to type something
  14. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Add more context to the prompt, but what exactly?
  15. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Show - and maybe enhance the response with additional information / actions
  16. Coding with an LLM Type your question Generate a prompt

    for the LLM Add context information Send final prompt LLM Receive Response Show and interpret the response Put code snippets from response into your project Be smart about where to and how to add code to the project
  17. Concrete Actions - We identify concrete actions where AI can

    help and provide a meaningful contribution - We craft the prompt with the necessary input, there is no user interaction - Not open-ended, very limited to a specific case Example: - 👍 Explain SpEL expression - 👍 Explain SQL/HQL/JPQL Query - 👍 Explain Pointcut expression - 🤔 CRON: eh, AI is too much for that, simple logic is enough
  18. Chat Agent - Enhance the prompt (with random information) -

    Fully open-ended / chat experience - Enhancing the result (buttons + better code merge) - The more structure you ask for, the better you can interpret / merge the result