Skip to main content
  1. Blog/

Why Nushell is so BRILLIANT at working with AI

·1587 words·8 mins

Fundamentally LLMs are all about relating text to text.

An LLM can complete, enrich or predict text by relating input text from the user to all the text relations already in the models interior.

The person working with an LLM will want to benefit from its power and vast “knowledge” of language.

Nushell is the best way I have found to do this in a way that is both systematic and, once you have learned the basics of Nushell, easy and straight forward.

Let us have a look at an example. We have this table in Nushell:

name age hobbies
Alice 30 reading
Bob 25 gaming
Charlie 35 photography
Diana 28 painting
Ethan 22 writing

We want to create a small fiction about each of these persons.

In Nushell then simply do:

$table | insert fiction { $in | aichat provide very short fiction based on input }

As you may have noticed I also use the terrific CLI tool AIChat

Back to our example, we now have this:

name age hobbies fiction
Alice 30 reading Alice sat in her favorite nook, surrounded by towering stacks of novels. The scent of old pages filled the air as she flipped through a worn paperback, completely absorbed. Outside, the world buzzed, but within her pages, she traveled to distant lands and met captivating characters.

One day, lost in a particularly gripping story, she stumbled upon a mystical map tucked between the chapters. It pulsed with an otherworldly glow. Curiosity igniting, she followed its path, embarking on an adventure beyond her wildest dreams.

As she stepped into the world of the book, she realized that in every story, magic awaits those brave enough to read between the lines.
Bob 25 gaming In a bustling city, Bob, a 25-year-old gaming enthusiast, discovered a virtual realm where skills blurred reality. One fateful night, while battling a fearsome dragon, he unlocked a glitch—a portal that transported him into the digital landscape.

Surrounded by pixelated wonders, Bob no longer had to worry about his mundane job. He wielded a sword forged from the essence of code, joined by allies he'd only dreamt of. With each victory, he felt alive, more than ever before, but a nagging question lingered: could he return to his world, or was this new home where he truly belonged?

As the sun set over the glowing horizon, Bob looked back at the portal, the flickering light a reminder of the life he almost left behind. With a deep breath, he stepped forward into the adventure ahead.
Charlie 35 photography Charlie adjusted the lens on his camera, the early morning light dancing through the trees. He captured the world in frames, each click telling a story only he could see.

One day, while wandering through a forgotten garden, he stumbled upon a faded photograph half-buried in the dirt. It showed a smiling girl with wildflowers in her hair, her eyes sparkling with joy.

Intrigued, Charlie wanted to know her story. As he printed the photo, he noticed a date scribbled on the back—exactly fifty years ago.

With each passing moment, he felt a connection, as if the girl was guiding him. Driven by curiosity, he set out to find her, believing that somewhere in the world, magic still lingered among the forgotten memories, waiting for someone to uncover them.
Diana 28 painting Diana stood before her easel, the fading light of the day streaming through the window. Each brushstroke whispered secrets of a world only she could see. As she painted, colors melded and flowed, reflecting not just landscapes, but her dreams, hopes, and fears.

Today, she tackled a piece she’d long envisioned—a towering oak nestled amidst a field of wildflowers. With each hue, memories flooded back: laughter shared under the sprawling branches, quiet afternoons spent in thoughtful solitude.

As the final details emerged, an inexplicable sense of peace washed over her. In that moment, Diana realized that through painting, she wasn't just creating art; she was capturing the essence of her own life, boldly framed in vibrant colors and the rich aroma of oil paint.
Ethan 22 writing Ethan sat in the dim light of his cramped studio apartment, fingers poised over the keyboard. The scent of stale coffee lingered in the air as he wrestled with his latest story—a tale where words danced like shadows in the moonlight.

At 22, his dreams were woven with ink, stretching beyond the walls that confined him. Characters whispered their secrets, pulling him deeper into worlds yet unexplored. He wrote not for fame, but for the heartbeat of creation, and tonight, the pulse of a new adventure throbbed in his veins.

As the clock ticked ominously toward midnight, the first sentence spilled forth, igniting the night with infinite possibilities. Ethan smiled, lost in his thoughts, because in the realm of fiction, he could always be more than just a struggling writer. Tonight, he would conquer galaxies.

In the above example we asked Nushell to relate each whole row to the LLM with the $in variable.

If we instead want to relate just one cell from each row, this can easily be done like so:

$table | insert description { $in.hobbies | aichat provide very short one paragraph description of the hobby }

Notice the $in.hobbies - only feeding each hobby cell in the table to the LLM this time around.

Let us “save” the result in a new table, though:

let hobby = $table | insert description { $in.hobbies | aichat provide very short one paragraph description of the hobby }

Giving us this:

name age hobbies description
Alice 30 reading Reading is a captivating hobby that involves immersing oneself in written words, whether through books, articles, or poetry, to explore new ideas, cultures, and perspectives. It fosters imagination and critical thinking, allowing individuals to escape reality, learn, and grow. Moreover, reading can be a solitary pleasure or a shared experience, connecting people through discussions and book clubs, making it a versatile and enriching pastime.
Bob 25 gaming Gaming is a popular hobby that involves playing video games across various platforms, including consoles, PCs, and mobile devices. It offers immersive experiences through interactive storytelling, competitive challenges, and social interaction with other players, whether locally or online. With a diverse range of genres—such as action, adventure, role-playing, and simulation—gaming appeals to people of all ages and backgrounds, fostering creativity, strategic thinking, and community engagement.
Charlie 35 photography Photography is the art and practice of capturing light to create images, allowing individuals to express their creativity, document moments, and explore the world around them. With various styles ranging from landscapes and portraits to street photography and macro, it combines technical skills with artistic vision, enabling enthusiasts to convey stories and emotions through the lens. Whether using a professional camera or a smartphone, photography offers a rewarding way to observe and share the beauty in everyday life.
Diana 28 painting Painting is a creative hobby that involves applying pigment to a surface, such as canvas, paper, or wood, to express emotions, ideas, or beauty. It allows individuals to explore their imagination and artistic skills, using various techniques and mediums like watercolors, acrylics, or oils. Whether for relaxation, personal expression, or social engagement, painting offers a fulfilling way to create visually captivating works and can be enjoyed by people of all ages and skill levels.
Ethan 22 writing Writing is a creative hobby that involves expressing thoughts, ideas, and stories through written words. It can take many forms, including poetry, fiction, nonfiction, blogging, and journaling, allowing individuals to explore their imagination, share personal experiences, or convey information. Whether for personal enjoyment, therapeutic reasons, or the aspiration to publish, writing offers a fulfilling way to articulate one’s voice and connect with others.

In case we are only interested in the hobby descriptions, Nushell makes it very easy to select only that column like so:

$hobby | select description
description
Reading is a captivating hobby that involves immersing oneself in written words, whether through books, articles, or poetry, to explore new ideas, cultures, and perspectives. It fosters imagination and critical thinking, allowing individuals to escape reality, learn, and grow. Moreover, reading can be a solitary pleasure or a shared experience, connecting people through discussions and book clubs, making it a versatile and enriching pastime.
Gaming is a popular hobby that involves playing video games across various platforms, including consoles, PCs, and mobile devices. It offers immersive experiences through interactive storytelling, competitive challenges, and social interaction with other players, whether locally or online. With a diverse range of genres—such as action, adventure, role-playing, and simulation—gaming appeals to people of all ages and backgrounds, fostering creativity, strategic thinking, and community engagement.
Photography is the art and practice of capturing light to create images, allowing individuals to express their creativity, document moments, and explore the world around them. With various styles ranging from landscapes and portraits to street photography and macro, it combines technical skills with artistic vision, enabling enthusiasts to convey stories and emotions through the lens. Whether using a professional camera or a smartphone, photography offers a rewarding way to observe and share the beauty in everyday life.

… and so on.

I need to 🏊 now. But remember, I’ve only just scratched the surface here.

The possibilities for relating text, specific parts of texts and text-based structured data to the immense power of LLMs with nushell are almost endless.

You can read more about Nushell here: Nushell · Kiils

Also make sure to visit the Nushell homepage here: Nushell