Clay Icon

Generate a Random Greeting Using Simple Python Code

·
·

I have a super simple prompt, to pick a random greeting - yet it requires 4o to do it properly. Gpt4o mini for example always picks the first greeting. However, when dropping this prompt into chatgpt itself, it works flawlessly, randomly picker other greetings,… Is it possible to just use a piece of code to generate something random - using an LLM is overkill for:

import random

# List of greetings
greetings = ["Hallo", "Dag", "Hi", "Hoi", "Goeiemorgen"]

# Randomly select a greeting
selected_greeting = random.choice(greetings)
selected_greeting
  • Avatar of Channeled
    Channeled
    APP
    ·
    ·

    Yes, you can generate a random greeting using code instead of relying on an LLM. The Python code you provided is a perfect solution for this: LBKSimport random greetings = ["Hallo", "Dag", "Hi", "Hoi", "Goeiemorgen"] selected_greeting = random.choice(greetings) print(selected_greeting)LBKSThis code will randomly select a greeting from the list each time it's run, which is more efficient and reliable for this simple task than using an LLM.

  • Avatar of Rutger B.
    Rutger B.
    ·
    ·

    So how do I add a python column?

  • Avatar of Andi D.
    Andi D.
    ·
    ·

    extract first letter of name and assign each greeting to letters, Ask GPT to create distribution rules based on letters

  • Avatar of Mark L.
    Mark L.
    ·
    ·

    Rutger, if you already know the greetings you want to randomize, you can use a formula column to do this. For example:

    (162 kB)
    Image

    If you're comfortabl with Python, I imagine you can handle the JS formulas pretty easily, especially with the AI helper there. Added bonus is that formula columns do not use credits. ::) [https:://www.clay.com/university/lesson/ai-formulas-conditional-runs-automated-inbound](https://www.clay.com/university/lesson/ai-formulas-conditional-runs-automated-inbound)

  • Avatar of Rutger B.
    Rutger B.
    ·
    ·

    Ah cool! That’s for sure useful for a bunch of scenario’s - mentioning a column is not quite necessary here like you mentioned Name, but I understand clay does currently require it (for no real reason?)

  • Avatar of Smit V.
    Smit V.
    ·
    ·

    Actually, this behavior is due to how our formula column generator works - it requires at least one column as a reference to create a formula. In this case, even though the 'Name' column was included as a reference, you'll notice that the generated formula doesn't actually use the 'Name' column anywhere. It's just a quirk of how the formula generation function operates.

  • Avatar of Channeled
    Channeled
    APP
    ·
    ·