首页 Java java教程 First Interaction With Open Source

First Interaction With Open Source

Sep 19, 2024 am 03:02 AM

Introduction

I've never thought that my hand will ever touch an open source, as it sounded like something unreachable to me. However, starting this semester I chose the course called "Open Source Development" by David Humphrey, not knowing what is waiting me, my expectation was like "Another boring course to fulfill my program", but once we started I realized that it is going to be something different from other courses. On the first lecture we were tasked with building a simple a CLI tool that allows us to use any compatible AI API endpoint in order to transform files in some helpful way. Probably, it changed my life. Literally, I have never been that passionated about programming, had thoughts that I don't belong to this sphere, but we all know that road isn't always straight, sometimes it's narrow. I witnessed so many students in our class which were so skilled, the only thought that revived my love to coding was: "Am I worse than them? Nahhh... It pushed me so hard, so I am sitting third week without leaving my laptop. I chose completely new language, started my research, and testings. Eventually, I came up with something simple, but interesting that helped me to understand that I can, literally, build anything I want.

PolyglotCode

PolyglotCode is a command-line tool that aids developers to translate their files with the code in ANY other programming language. This tool was written in Java using Maven dependencies manager. It simply takes file, language user wants to translate sends it as a query to the API endpoint and outputs translated material to the terminal or writes it to the file (user's choice.) Going forward, I want to mention that I used Cohere's AI v1 endpoint.

First Interaction With Open Source

I uploaded video with detailed demo of the tool.

Getting Started

Step 1. Generate and provide Cohere API key into the defaultValue of -a && --api-key flag inside of the main class:

@Option(
        names = {"-a", "--api-key"},
        defaultValue = "YOUR_API-KEY",
        description = "Modifying api key manually"
)
private String api;
登录后复制

or

Specify call and provide the api-key into the command line, using flags(Available only after Step 3) :

./polyglot <file(s)...> <language> -a <YOUR-API-KEY>
登录后复制

Step 2. Make bash script executable, so user would be able to use ./polyglot command to run code

chmod +x polyglot
登录后复制

Step 3. Run Maven Package to compile the source code

mvn package
登录后复制

Features

For the reason, that is release v0.1, I was struggling crafting this tool(struggling, I mean it took a lot of time I ENJOYED IT :D) it doesn't contain all the features that I planned to implement. However, it still contains some of the required features, I just simply was following the requirements. So here they are:

Help

Isn't peak of programming, (-h, --help) flags. This flag helps user to learn the usage and all flags. Usage:

./polyglot -h
登录后复制

or

./polyglot --help
登录后复制

First Interaction With Open Source

Version

Another peak of programming is (-v, --version) flag. Shows current version of the tool. Usage:

./polyglot -v
登录后复制

or

./polyglot --version
登录后复制

First Interaction With Open Source

Api-Key

As it was mentioned earlier, user is able to specify Cohere-Api key without going into the code, simply using flags (-a, --api-key) Usage:

./polyglot <file(s)...> <language> -a <YOUR-API>
登录后复制

or

./polyglot <file(s)...> <language> --api-key <YOUR-API>
登录后复制

BaseUrl

It is not recommended to change the baseUrl of this application, as it may produce an unexpected output; however this option is still available to the user. Usage:

./polyglot <file(s)...> <language> -u <baseUrl>
登录后复制

or

./polyglot <file(s)...> <language> --base-url <baseURL>
登录后复制

First Interaction With Open Source

Output

Creates the file, specified by user and writes the result there. It's highly recommended to use this option with one file at the time. Usage:

./polyglot <file(s)...> <language> -o file.txt
登录后复制

or

./polyglot <file(s)...> <language> --output file.txt
登录后复制

First Interaction With Open Source

How it looks in the new file:

First Interaction With Open Source

Challenges I faced

After I shared all my features with you, it's time to talk about the challenges that I faced. One of the challenges was learning new language, it wasn't that hard as I learnt before C/C++. Second one was finding appropriate AI endpoint because many of them wouldn't be that developed to answer even simple questions, and my goal was to find it for free :) Third challenge came with learning the usage of picoCLI, tool that helps you to setup CLI tool, at first I created a bash script to help me with it, I was trying to avoid use of picoCLI, then It became soooo inconvenient, and I decided to learn about picoCLI better.

Overall, this project helped me to understand that everything is possible, if you work hard!

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

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

<🎜>:泡泡胶模拟器无穷大 - 如何获取和使用皇家钥匙
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系统,解释
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆树的耳语 - 如何解锁抓钩
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Java教程
1671
14
CakePHP 教程
1428
52
Laravel 教程
1329
25
PHP教程
1276
29
C# 教程
1256
24
公司安全软件导致应用无法运行?如何排查和解决? 公司安全软件导致应用无法运行?如何排查和解决? Apr 19, 2025 pm 04:51 PM

公司安全软件导致部分应用无法正常运行的排查与解决方法许多公司为了保障内部网络安全,会部署安全软件。...

如何将姓名转换为数字以实现排序并保持群组中的一致性? 如何将姓名转换为数字以实现排序并保持群组中的一致性? Apr 19, 2025 pm 11:30 PM

将姓名转换为数字以实现排序的解决方案在许多应用场景中,用户可能需要在群组中进行排序,尤其是在一个用...

如何使用MapStruct简化系统对接中的字段映射问题? 如何使用MapStruct简化系统对接中的字段映射问题? Apr 19, 2025 pm 06:21 PM

系统对接中的字段映射处理在进行系统对接时,常常会遇到一个棘手的问题:如何将A系统的接口字段有效地映�...

IntelliJ IDEA是如何在不输出日志的情况下识别Spring Boot项目的端口号的? IntelliJ IDEA是如何在不输出日志的情况下识别Spring Boot项目的端口号的? Apr 19, 2025 pm 11:45 PM

在使用IntelliJIDEAUltimate版本启动Spring...

如何优雅地获取实体类变量名构建数据库查询条件? 如何优雅地获取实体类变量名构建数据库查询条件? Apr 19, 2025 pm 11:42 PM

在使用MyBatis-Plus或其他ORM框架进行数据库操作时,经常需要根据实体类的属性名构造查询条件。如果每次都手动...

Java对象如何安全地转换为数组? Java对象如何安全地转换为数组? Apr 19, 2025 pm 11:33 PM

Java对象与数组的转换:深入探讨强制类型转换的风险与正确方法很多Java初学者会遇到将一个对象转换成数组的�...

电商平台SKU和SPU数据库设计:如何兼顾用户自定义属性和无属性商品? 电商平台SKU和SPU数据库设计:如何兼顾用户自定义属性和无属性商品? Apr 19, 2025 pm 11:27 PM

电商平台SKU和SPU表设计详解本文将探讨电商平台中SKU和SPU的数据库设计问题,特别是如何处理用户自定义销售属...

如何利用Redis缓存方案高效实现产品排行榜列表的需求? 如何利用Redis缓存方案高效实现产品排行榜列表的需求? Apr 19, 2025 pm 11:36 PM

Redis缓存方案如何实现产品排行榜列表的需求?在开发过程中,我们常常需要处理排行榜的需求,例如展示一个�...

See all articles