Hey everyone, welcome back to the Data and AI
with Mukundan podcast. Today's episode, I want
to talk about how we can use AI to turn Python
code into an emotionally engaging blog post.
Right. So welcome back and if you're a developer,
content creator or someone who just wants to
communicate technical work without sounding like
a robot, this one's for you. Today, I want to
take you behind the scenes of a project that
I built recently. It's called Code to Story Pro.
It's a tool that turns Python code into emotionally
resonant blog posts using GPT -4. So this episode
isn't just about automation. It's also about
storytelling, right? So you write something really
amazing, super amazing code. But you need to
be able to tell a story from it. And that's the
goal here. Because your code can be only good
as what it's trying to tell. You should be able
to explain what you've written. Especially this
is for people who are busy. It's basically about
connecting through code without needing to manually
explain every single line. In this episode, I'll
walk you through the problem that we're trying
to solve and why traditional methods of documentation
just doesn't cut it anymore. And we'll see how
this tool works, the story behind building it,
and where I think this is all headed next. Right?
So, why do we need CodeToStory Pro? Let's start
with the problem. Think about the last time that
you wrote some code. Maybe it was for a class
project. Maybe for work. Maybe even a hackathon.
So, you wrote it, you shipped it, you committed
it. And maybe if you were lucky, you wrote a
one -line comment or a readme. Now, fast forward
three months. teammate at work or maybe your
you know classmate at school or even a recruiter
or or your future self is looking at the same
code and they're stuck because code while powerful
it doesn't explain why because well people are
busy we don't always have the time to write compelling
documentation let alone full -fledged blog posts
but we know how valuable those posts are they
help us reflect they help others learn they can
be your best work portfolio right and that's
where code to story pro comes in so what it does
so what does what does code to story pro really
do in short you just you paste your code then
you pick a tone like formal or casual you pick
an emotion maybe you want it to sound empowering
or even frustrated like you were when you were
banging your head on the keyboard then you pick
a structure tutorial story first or a problem
solution structure so then you just click the
button that generates a blog post and GPT -4
which is working in the backend turns that code
into a title a summary a full blog post and three
social media snippets that you can use for LinkedIn
twitter and reddit and all within 30 seconds
see here's the real pain point let's dig deeper
into why this matters so writing clear code is
important but communicating what that code means
is just as important if not more And it's not
just a nice to have. It's actually like a super
game changer for your job applications, for the
team knowledge sharing and for your own individual
learning. And there's also the emotional friction
to this, right? If you're a student who, you
know, you might want to... Make your project
sound inspiring. You want to inspire your teammates,
your friends, maybe even your college professor,
right? And if you're sending it to a manager,
you want to sound formal. If it's your friend,
maybe you want it to sound a little playful,
right? And that flexibility is built into Code
to Story Pro. and that makes it more than just
like your random summarizer right it's it's not
just a summary it's it's a storyteller and you
want your code to tell a story so let's look
at how it works let's talk about this how it
works technically right here's how the ui here's
how the tool is built The UI is basically made
with Streamlit and that's a Python based library
for front -end and I use it for all of my projects
really it's very easy to do if you're not familiar
with my work with my podcast as well something
I keep talking about but if you're new here that's
something I use to build very quick front -end
code um so the ui is made with streamlit it's
very clean fast and web accessible so what i
used here was multi -select boxes to choose the
tone emotion and structure and when you click
generate it sends a custom prompt to gpt4 through
the openai api so the code is included in that
prompt along with your tone and structure settings
so gpd4 then responds with the entire formatted
blog post then it breaks the response in two
parts like title summary blog and social posts
those get rendered in the app so i just mentioned
this earlier as well you click on the generate
blog and it will give you the title summary blog
and the social posts for LinkedIn, Reddit, and
so on. And all of this just gets rendered in
the app itself, the website app in Streamlit.
We also make sure that if the AI skips any section,
the app doesn't break. And that kind of fail
-safe matters when you're trying to build it
for production. Honestly, I just built this out
of frustration. I kept finding myself wanting
to share projects, but not having the energy
to sit down and write a full blog post from scratch.
And I also thought like, well, you know, this
isn't something that I can, you know, I can use
now. It was something I wish I had earlier, right?
this is if if ai was available to us at the time
when i was starting out um this kind of tool
really helped and it's not to say that i have
any regrets there but just saying someone new
who's just starting out they can use this tool
so if you're new in the coding field you just
started out to become a programmer today you
want to be able to share your work with your
recruiters or your teammates right and i just
think like if it's something that i wanted to
use now and i wish i could have used earlier
someone else has the same feeling and if they're
starting out as well they can be going through
the same set of motions that i'm going through
right um because everybody wants to share their
work but just having to do all of that extra
work to um make it sound english right um for
my or any language for that matter right um you
want your code to tell a story which uh you don't
want to spend enough i mean you want to maybe
focus on the next project and go to story just
takes care of this I would say manual work for
you. It's manual work for me. It could be something
that other people enjoy doing. And usually if
you're a developer, for me, I'm an analyst and
I don't enjoy, you know, just telling a story
all the time. There are times when I wish there's
some automations there. So something like this
tool would definitely help, right? You know,
an analyst, data scientist, something like this
helps, right? And for me, it was taking like
three to five hours to write something thoughtful.
It's not because it takes actually three to five
hours. It's just procrastination. And as someone
who loves to build, it just feels like a bottleneck
to me. Because I knew I had the code. I knew
I had the insights. I just didn't want to spend
a whole afternoon formatting paragraphs. And
with GPT -4, I just realized I didn't have to.
But I didn't want the output to feel generic.
So I built this multi -select system. Now I can
choose exactly what tone I want. Maybe one day
I want to sound technical. Maybe another day
I want to be more poetic, right? And that kind
of flexibility is available in the app. You can
obviously add more emotions to it. Train your
AI to do that. So let's try to break this code
down in plain English. First, we import the Streamlit
library and OpenAI library and a few helper packages.
So we set up the Streamlit app UI and input area.
Then we let the user pick options for tone, emotion
and structure. And when the user hits generate,
the app builds a custom GPT -4 prompt. And so
it then sends that prompt to GPT -4 using the
OpenAI Python client. And GPT -4 then replies
with a formatted blog post. So we then pass that
text and render it inside the app. and it's about
100 lines of code but it creates something that
feels like magic so i mean you i'm sure you've
written longer pieces of code in your uh career
so career but 100 lines of code is not too much
but the thing is it creates something which really
feels like you know an uber cool thing um so
let's look at some use cases for this here's
how you might end up using code to story pro
so you i already talked about some others but
just wanna put it in a section right so you're
applying for jobs and you want to turn your portfolio
project into a blog you want to teach something
technical but don't want to start from scratch
you're a pm or a founder who received some code
and want a quick summary in plain english or
if you're giving a talk and want to create a
script or show notes from your code you get to
decide that tone that makes it incredibly flexible
so what's next for this what's next for code
to story Pro so I'm working on a few things where
which is including like let users upload dot
py files directly instead of copy pasting uh
right now it's a copy paste thing so that is
something i'm working on and adding image generation
so basically turning code into diagrams um again
you'll want your call to tell story and i'm aiming
to do i'd like more emotion and that piece too
an image right so turn an emotionally engaging
code into diagrams right in a way and integrate
with blogging platforms so you can one click
publish that would be ideal that would be something
that would take an extended period of time i
think but that'd be an interesting use case and
maybe letting you train a custom tone like your
voice your style so right now there's like more
inbuilt tones right um it's like more hard -coded
tones so more custom tones like how you want
to exactly sound um and if you're someone who
creates technical content i want this to be a
secret weapon if you're turning your technical
code into really amazing stories well the world
is world is yours so if i were to reflect we
are entering an age where communication matters
more now than ever and ai isn't just for generating
code anymore it's helping us explain share and
connect so the way we tell stories around our
code can change careers it can build communities
and now it doesn't have to take hours so with
code to story pro you don't just generate documentation
you generate meaning so thanks for listening
and if you want to try code to story pro just
drop me a message i will be adding uh the link
to what i've already built it's a medium blog
and you can check it out you need a medium account
for this uh but if you want it for you know if
you don't have a medium account just drop me
a ping on my sub stack so that is another place
where i'm planning to put this code out Just
so you don't need a medium account and the Substack
one is for free. So just drop me a message there.
Again, links to both will be there in the show
notes. And I'd love your feedback. And if this
resonated with you, please share it with a fellow
builder, a creator or a writer. And until next
time, just... keep building keep writing and
keep telling the stories that the code wants
you to tell because you are amazing