Developing with ChatGPT
Tags: chatgpt, python, programming, ai
Published: 2023-04-24 08:55:24

Are you curious about the possibilities of ChatGPT and how it can be used in your own projects? With the recent exciting advancements in language models and generative AI, there's never been a better time to dive in and start experimenting. In this blog post, I'll be sharing my own journey of developing a personal assistant using ChatGPT - from the challenges I faced to the solutions I discovered along the way.

As someone who has been following the exciting advancements in language models, generative AIs, and artificial intelligence, I couldn't wait to dive into the world of ChatGPT. It represented a paradigm shift in the way we think about natural language processing.

For me, it was a clear sign that I needed to start taking learning about these topics more seriously, so I embarked on a [personal project](https://github.com/juanmirod/chatgpt_cli) to create my own personal assistant using ChatGPT. I wanted to experiment and learn at my own pace, without the constraints of a directed course.

My ultimate goal was to develop an assistant that really knew me - one that would remember our previous conversations and run on my own personal computer. Even if I never quite achieve this lofty ambition, I knew that working on this project would be a fantastic way to immerse myself in the topic.

To make things even more challenging, I decided to use Python - a language I wasn't particularly proficient in - and to always rely on ChatGPT instead of turning to Google or external documentation. This created a project that was not only challenging and exciting, but also incredibly meta. By using ChatGPT to develop tools that will ultimately replace it with my own personalized version.

For now the experience is great. I develop new functionality very quickly, ChatGPT unlocks me very often and keeps me much more in the flow than having to read documentation or search Google and in general the feeling of speed and satisfaction is great. I also believe that this is because I'm using ChatGPT in the ideal scenario: 

- A new and small project, a command-line app, so adding functionality is very easy, you don't need frameworks or components or big architectures

- In a language I don't master, ChatGPT is very useful to solve doubts, and the domain itself is ChatGPT's specialty. 

- Python is a language especially suitable for LLMs because it has less syntax and is dynamic. Properties that make it ideal for humans and LLMs because right now it's the closest thing we have to programming in natural language. 

Without all these factors, the usefulness of ChatGPT starts to degrade for me. In fact, at work I use it much less often, it's just harder to explain what I want than to do it myself. But that's why I think we will all end up with our own personal or company assistant who knows the ins and outs of our projects and can help us with more context... 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdgjzlr75eczxhmj4vb5.jpg)

But let's get to the point, I'm going to list some examples of how I've used ChatGPT in this project and when I can I'll link to specific conversations about that topic that I had with ChatGPT. These are some things I've done with ChatGPT to work, not just to explore what it knows, learn or try to play or entertain myself:

- **Readme**: The first version of the Readme was written by ChatGPT, I edited it and have been expanding and improving it since then.[Read the conversation here](https://gist.github.com/juanmirod/fce0104af6714c7527fce54639706407)

- **Dockerfile**: I asked ChatGPT for a dockerfile because to be honest I don't know the syntax by heart and I always end up copy-pasting. At first it gave me a completely functional dockerfile and the command to execute the assistant from the dockerfile. Then I edited it a bit to remove some things I didn't need and change the order of the commands a bit to better use docker's cache.[Conversation](https://gist.github.com/juanmirod/7be1a16f017ea8798754870d1bcd7ffa)
 
- **TTS**: The assistant has a text-to-speech option so you can listen to its responses, although by default I have it disabled (it's faster to read and the code doesn't make sense to listen to). The first version was again its own, then I tried several voices and libraries, and in the end I settled on one that wasn't the one ChatGPT suggested.
 
- **Upload conversation to a gist**. I also asked ChatGPT for the upload file, then I put the code into a function to use it from the app instead of as a script.[Conversation](https://gist.github.com/juanmirod/8b6044b0071bdcc5cb0bbcf933b7a576)
 
- **Retrieve a conversation parsing the markdown file**. This is not integrated yet, but I've already played with ChatGPT and have the initial code that should make it possible.[Conversation](https://gist.github.com/juanmirod/4f0e8687b4620831afb1446aed027b0c)
 
- **Refactors**. I've done several refactors where I've given it a big function and asked it to split it into smaller functions.
 
- **Tests**. The first tests of the ChatGPT class were done by ChatGPT, and the ones for the actions module were done with copilot's help. 

In general ChatGPT has helped me throughout the process. from outlining solutions, consulting how libraries work, writing tests... The pattern is similar every time, and that's why I think it's especially useful if you don't master the language, because if you do, you'll take the same time or less to write it yourself. But if you don't know the available libraries and modules, asking ChatGPT how it would do it saves a lot of time in trial and error and research and reading documentation.

Besides, for me this process is usually a rabbit hole: I start looking for a library to do X and there are 10's, and now I have to see which ones are more popular and why, and I want to see a little how they work... and when I realize it's been 2 hours and I haven't done anything. With ChatGPT all that process is much more immediate and fluid, even if I end up using another library or heavily editing or discarding its first solution. It keeps me more in the flow and more focused on the problem than all those websites full of ads and cookie popups, videos and other distractions. 

I'm sure I'm only scratching the surface here. LLMs seem to have a lot of potential at various levels, and little by little we'll be integrating them into IDEs and user interfaces, but even in this rudimentary form and without knowing very well what I'm doing I think I gain a lot of productivity and the development process is much less frustrating.

Thanks a lot for reading, if you got this far please tell me what you think in the comments. Have you used ChatGPT for programming? Do you have a specific setup or workflow? I would love to know about it!

---

This blog post was translated by ChatGPT from the original Spanish one which you can read [here](http://juanmirod.github.io/2023/04/16/trabajando-con-chat-gpt.html)