Category: Generative AI

  • Converting DrawIO Diagrams to Terraform

    I’m going to start this post of by saying that I need testers. People to test this process from an interface perspective as well as a data perspective. I’m limited on the amount of test data that I have to put through the process.

    With that said, I spent my Thanksgiving Holiday writing code, building this project and putting in way more time that I thought I would but boy is it cool.

    If you’re like me and working in a Cloud Engineering capacity then you probably have built a DrawIO diagram at some point in your life to describe or define your AWS architecture. Then you have spent countless hours using that diagram to write your Terraform. I’ve built something that will save you those hours and get you started on your cloud journey.

    Enter https://drawiototerraform.com. My new tool that allows you to convert your DrawIO AWS Architecture diagrams to Terraform just by uploading them. The process uses a combination of Python and LLM’s to identify the components in your diagram and their relationships, write the base Terraform, analyze the initial Terraform for syntax errors and ultimately test the Terraform by generating a Terraform plan.

    All this is then delivered to you as a ZIP file for you to review, modify and ultimately deploy to your environment. By no means is it perfect yet and that is why I am looking for people to test the platform.

    If you, or someone you know, is interested in helping me test have them reach out to me on through the website’s support page and I will get them some free credits so that they can test out the platform with their own diagrams.

    If you are interested in learning more about the project in any capacity do not hesitate to reach out to me at anytime.

    Website: https://drawiototerraform.com

  • Product Name Detection with AWS Bedrock & Anthropic Claude

    Well, my AWS bill me a bit larger than normal this month due to testing this script. I thoroughly enjoy utilizing Generative AI to do work for me and I had some spare time to tackle this problem this week.

    A client sent me a bunch of product images that were not named properly. All of the files were named something like “IMG_123.jpeg”. There was 63 total files so I decided rather than going through them one by one I would see if I could get one of Anthropic’s models to handle it for me and low and behold it was very successful!

    I scripted out the workflow in Python and utilized AWS Bedrock’s platform to execute the interactions with the Claude 3 Haiku model. Take a look at the code below to see how this was executed.

    if __name__ == "__main__":
        print("Processing images")
        files = os.listdir("photos")
        print(len(files))
        for file in files:
            if file.endswith(".jpeg"):
                print(f"Sending {file} to Bedrock")
                with open(f"photos/{file}", "rb") as photo:
    
                    prompt = f"""
                        Looking at the image included, find and return the name of the product. 
                        Rules: 
                        1. Return only the product name that has been determined.
                        2. Do not include any other text in your response like "the product determined..."
                        """
                    model_response = bedrock_actions.converse(
                        prompt, 
                        image_format="jpeg",
                        encoded_image=photo.read(),
                        max_tokens="2000",
                        temperature=.01,
                        top_p=0.999
                        )
                    print(model_response['output'])
                    product_name = modify_product_name(model_response['output']['message']['content'][0]['text'])
                    
                    photo.close()
                    if os.system(f"cp photos/{file} renamed_photos/{product_name}.jpeg") != 0:
                        print("failed to move file")
                    else:
                        os.system(f"mv photos/{file} finished/{file}")
        sys.exit(0)

    The code will loop through all the files in a folder called “photos” passing each one to Bedrock and getting a response. There was a lot of characters that were returned that would either break the script or that are just not needed so I also wrote a function to handle those.

    Ultimately, the script will copy the photo to a file named after the product and then move the original file into a folder called “finished”.

    I’ve uploaded the code to GitHub and you can utilize it however you want!