How to leverage LLMs for writing technical documentation and unit tests

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 12

  • @QuadDrums
    @QuadDrums Місяць тому +1

    This channels needs more viewers this content is great

    • @cmd_labs
      @cmd_labs  Місяць тому

      Appreciate it. Great to meet you @QuadDrums

  • @nicholasdelnegro6936
    @nicholasdelnegro6936 Місяць тому +1

    love it

  • @gothfather8741
    @gothfather8741 21 день тому +1

    You went from being the "GG Allin of hip-hop" with the dadaist approach, to a technology expert in a few short years - very happy for your success and direction you've gone!

  • @gothfather8741
    @gothfather8741 21 день тому +1

    Thanks for sharing this interesting and helpful productivity tip!
    I'm a bit old school...I always start a large development project with documentation - conceptual, sequence, data relationship, activity and other diagrams (what documentation is applicable varies per case and complexity of what I'm building) and a summary of the highlights of the application.
    Then before I start writing code I document the classes, methods, etc. before I even write the logic. Then I start writing the code and I document as I go, never leaving it to the end as an afterthought. While coding, valuable things may come to your mind to be captured as documentation, that may be forgotten if not recorded right away.
    Unit tests I do very early in the development process. I prefer creating the unit test classes at least with empty methods stating "given/when/then" right after I'm done the functional class containing business logic.
    I like the idea of using AI to help document code which, for whatever reason is lacking in documentation. I also like the idea of AI helping write better unit tests and ensure a good amount of coverage is met. However, I don't think AI should be a substitution for writing meaningful unit tests and documentation.
    Copilot is a great option. Some companies are training AI to teach it their frameworks (industry and homegrown) in order to help developers write better code faster. I really hope people use it the right way and don't get lazy expecting AI to do the thinking for then. It is a tool and should not be a crutch.
    Cheers!

    • @cmd_labs
      @cmd_labs  21 день тому

      An approach I think worthy of exploring would be to generate code from documentation instead of the other way around as shown in this video
      I've seen some other developers implementing this approach
      I appreciate the engagement
      Sending lots of love

    • @gothfather8741
      @gothfather8741 21 день тому +1

      ​​@@cmd_labsyou know what, that was possible using the old RationalRose software and others circa 2007. Haven't done that approach for a while; the tooling at work is a little constrained at the moment. However, generating good code from really good documentation is an excellent approach, and I think AI will immensely help for that! Of course, the code needs to be reviewed very thoroughly, PRs need to be manually reviewed and approved and testing is paramount, etc.

  • @prajwalpadole5558
    @prajwalpadole5558 Місяць тому +1

    could this llm model be integrated with own mern stack project
    if yes ,how ? can you give short idea
    really loved the content , appretaite it .

    • @cmd_labs
      @cmd_labs  Місяць тому

      Great to meet you @prajwalpadole5558!
      You can ABSOLUTELY integrate this technique with your MERN stack application...
      Create a folder called "scripts" at the root of your project and add a file inside called "gen_docs.py" or "gen_tests.py" (depending on what exactly what you want to do)
      If you already have a folder where you hold useful scripts related to developing your project then you can store the following scripts there too...
      I personally don't mind mixing programming languages within projects but if you want to stay consistent with Javascript/Typescript you can copy/paste the provided Python scripts to ChatGPT and have them rewritten in Javascript/Typescript for you. And then you'll be able to add files called "gen_docs.ts" or "gen_tests.ts" and copy/paste in the rewritten Javascript/Typescript code.
      Here are the 2 scripts showcased in the video...
      gen_docs script - github.com/Kalygo-io/kalygo3-ai-api/blob/main/scripts/gen_docs.py
      gen_tests script - github.com/Kalygo-io/kalygo3-ai-api/blob/main/scripts/gen_tests.py
      These 2 scripts have a simple API...
      1) FOR THE "gen_docs" SCRIPT, you list the files that you want to document as well as the name of the generated documentation file...
      github.com/Kalygo-io/kalygo3-ai-api/blob/13a27062f6c29df7f3760a002fe4c6a2e0ca0e40/scripts/gen_docs.py#L59
      Also you can tweak the prompt used for generating the documentation to your application...
      github.com/Kalygo-io/kalygo3-ai-api/blob/main/src/core/prompts/DOCUMENTATION_WRITER.py
      The "DOCUMENTATION WRITER" prompt is held in a separate file to not bloat the "gen_docs" script
      AKA you will want to edit the DOCUMENTATION writer to be specialized in Javascript/Typescript instead of Python
      2) FOR THE "gen_tests" SCRIPT things are a bit trickier but generally similar to the "gen_docs" script. In the example shown in the video, you list each class you would like to generate unit tests for as well as the path where the class sits in your project
      github.com/Kalygo-io/kalygo3-ai-api/blob/13a27062f6c29df7f3760a002fe4c6a2e0ca0e40/scripts/gen_tests.py#L54
      You can also tweak the prompt used for generating the unit tests as well...
      AKA you will want the TESTS_WRITER to be specialized in Javascript/Typescript and which test framework you are using aka Mocha or Jest etc.
      github.com/Kalygo-io/kalygo3-ai-api/blob/main/src/core/prompts/TESTS_WRITER.py
      Note how in this TESTS_WRITER prompt I include a lot of contextual information about the application in which the class to generate unit tests for sits
      As I mention in the video, I have found that the generate unit tests often times have bugs that need to be fixed
      If you are lazy you can just delete the lines of generated test code giving you issues.
      ALSO make sure you audit the generated unit tests to make sure they are not doing anything malicious : )
      ua-cam.com/video/VtJKQHoyb2A/v-deo.htmlsi=xn6sOWZHyBFY7W8l&t=211
      Did I miss anything?
      Let me know how it goes!

  • @gothfather8741
    @gothfather8741 20 днів тому +1

    Would you be adverse to me emailing you a few questions I was thinking of asking ? It is about your musical career. I don't want to impose and totally understand if you're not comfortable as I respect people's privacy. I simply don't want to post the questions on UA-cam.

    • @cmd_labs
      @cmd_labs  20 днів тому

      @@gothfather8741 go for it
      I have nothing to hide
      But yea at the same time each platform has its nuances