DEV Community

Christian Duarte
Christian Duarte

Posted on

Week 4, Lab 3

LAB

Merging branches...

In this week's lab, I made changes in branches, and pushed + merged them into my main repository branch.

The 2 issues that I created were for adding features of 1: Allowing for multiple files and entire folders to be submitted into the tool through CLI arguments. And 2: Allowing for a user to type --stream or -s and have the program print the lines of dialogue from the Ollama AI model back in real time as it generates them.

Files & Folders

Before this issue was complete, the program could be run by passing in a file as an argument, whether you called it as:

bun f2 example.py example_2.py

OR

bun f2 src/example.py src/examples/example_2.py example_3.py

It would only take in individual files.

By setting up code that will take in multiple files like this, and then adding in the functionality to also include directories to be passed, this allows a user to simply name a directory, and all the files within that folder will be parsed to the AI LLM and returned as a README.md file explaining the contents.

Portion of code:

Image description

If you would like to see ALL OF the changes I made in regards to this issue, you can visit them here:

https://github.com/cduarte3/f2read/commit/c9ef383ed63bf71d8d940eba92c986c99402fb31

Streaming

In this lab, I learned about and implemented a new feature called streaming. By passing an argument to the Ollama model of stream:true, I was able to receive text formatted in a way that could be printed line by line to the user as it is generated by the model. This allows for a user to see in real time how the model is responding to their CLI interaction.

Portion of code:

Image description

If you'd like to see the REST OF the changes made in regards to this feature, please visit:

https://github.com/cduarte3/f2read/commit/9ed339431bfa361b360bcaf87ebf101780883d42

What I learnt...

Through this lab, I learned that when working on separate features, it is a better practice approach to work on them in separate branches. A lot of times in the past, I would start a feature on a branch or on the main branch if it is a solo project, and work on multiple features before committing.

By working on parallel branches for multiple features, this allows me to work more efficiently as I can switch to the other branch and work on a different feature if I am having issues rather than forcing something very crude and unfinished to work in order to work on a different aspect.

In the future, and for next time, I think it is good that I adopt this approach into my programming habits. By approaching implementing my functionalities in this way, I can have a more effective and efficient way of completing my personal side projects, and my college group coursework.

Top comments (0)