首页 > 后端开发 > Python教程 > First collaboration!

First collaboration!

DDD
发布: 2024-09-19 10:37:32
原创
362 人浏览过

First collaboration!

For this week lab, we are tasked to contribute onto someone else's work through GitHub. What we needed to do is add a new feature in their project that outputs the token info and we needed to trigger that feature with a command line flag.

Her project was creating a readme file for a source code using OpenAI.

First thoughts.

My first thought on collaborating on another work is that I would need to learn their coding style and the language that they used. I'm primarily more familiar with C++ and JavaScript but almost never touched Python. That was an interesting learning experience, scouring the internet for information on how to code with Python. Thankfully it wasn't too complex of a project and the comments and documentation was great. They were easy to understand.

How I implement the new feature.

After learning how to code with python, I'm now ready to start implement the feature. What I needed to do was figure out how she is doing the cli commands flags. It took several attempts on figuring it out how it works but finally I manage to add a command flag without breaking anything.

After that I needed to add a function that outputs the token usage info. That part wasn't too hard to figure out since I used the same OpenAI provider, Groq. It is mostly a copy of one of her function where it gets the chat completion response from the LLM but more trimmed. I could have trimmed it more to reduce redundancy but I do not want to alter her code too much. So instead just added a new function.

Pull request

After I was done with my implantation I was ready to create a pull request. But she made updates to her project. So first I need to sync with her repo first. Their was a few conflicts but manage to resolve all of them without too much of an issue. Then I just made a pull request, in the description I added, everything I did, did not forget to comment my work and how the new command flag works.

Overall

This was my first time contribute to another work. I find this was a good learning experience. I know that figuring some else coding style will eventually something I need to be efficient at later. Especially almost always be working with someone else or with a team. This also made me think that I cannot slack off on commenting my source code. Because someone may need to review it or alter it. It is easy for me to understand my own code but not for someone else. Documentation is king!

以上是First collaboration!的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:dev.to
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板