Learn New Things Everyday: First Pull Request
Amir Mullagaliev
Posted on September 19, 2024
Background
This blog is about the lab02 for Open-Source Development course. We were tasked with finding a partner from our course and contribute to their project , so tool would be able support -t
and --token-usage
flags to display token usage information: amount of prompt_tokens, completion_tokens and total_tokens. Important to mention that one of the open source rules is to contribute in the same coding style, as it was written before.
Partner's Project
I found my partner using our slack community, his name is Theo, and he's got a wonderful project completely written in Rust
called mastermind. Mastermind is a CLI tool designed to generate clue words for spymasters in the game of Codenames, leveraging large language models (LLMs) of your choice!
First Rust
Experience and PR
For the reason, that I am using Rust
first time in my life, I had to understand basic concepts of this language. It took me a while; however, my partner helped me and shared all relevant documentation for this project. I opened Issue and started working on it. Even though everything was provided to me, Rust
syntax seamed weird to me, and first couple of hours, I was doing insane things for people that know the language. Afterwards, to add support of -t
and --token-usage
, I came up with following commits:
- Created new structure called
Usage
that has three attributes:prompt_tokens
,completion_tokens
andtotal_tokens
.- Added new attribute to struct
ChatCompletionResponse
that was created in previous steps.
- Added new attribute to struct
- Changed function
fetch_clue_collection()
to return tuple, instead of justClueCollection
, it returned another object calledUsage
. - Changed
main.rs
file to make available new feature and output it tostderr
. - Changed
README.md
to document a new feature.
Once I made all these changes, I committed, pushed and created pull request that was linked to an issue
Feedback and Changes
Eventually, I received a feedback by my partner, that suggested to adjust couple of things in my PR:
- struct
ClueCollection
received the same attribute asChatCompletionResponse
,Usage
. - Adjustment above means, that function
fetch_clue_collection()
inchat_completion.rs
file returns only one objectClueCollection
that also contains usage information.
I pushed all the changes above. Eventually, after changing my pull request, it's got accepted and merged.
Result
Using -t
or --token-usage
flag gives us following output:
Challenges
The only problem that I had is Rust
because, as I mentioned above was new language to me, that wasn't like any other language.
I would do completely the same, If I were to do it again.
PR I received
Before I started contributing to Theo's project. The way how I found his repo is I used slack to find a partner. In a morning I received couple of emails about someone created an issue and pull request, I started reviewing it. To be honest, I felt that I am a teacher or something, never had an opportunity to review someone's code; however, it wasn't first one, but never had pull request, and in github marked as first Code Review
.
Lets get back to the PR, the only thing that It missed number of total_tokens
. I requested changes, and I received them back in couple of hours, reviewed once again, approved and merged. PR and issue were closed.
Conclusion
In conclusion, this lab was really interesting to do. It gave me first experiencing contributing in someone's repository, without including first lab. I learnt how to create, review and merge pull requests.
Thank you, Theo!
Posted on September 19, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.