Home Java javaTutorial 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;
Copy after login

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>
Copy after login

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

chmod +x polyglot
Copy after login

Step 3. Run Maven Package to compile the source code

mvn package
Copy after login

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
Copy after login

or

./polyglot --help
Copy after login

First Interaction With Open Source

Version

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

./polyglot -v
Copy after login

or

./polyglot --version
Copy after login

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>
Copy after login

or

./polyglot <file(s)...> <language> --api-key <YOUR-API>
Copy after login

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>
Copy after login

or

./polyglot <file(s)...> <language> --base-url <baseURL>
Copy after login

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
Copy after login

or

./polyglot <file(s)...> <language> --output file.txt
Copy after login

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!

The above is the detailed content of First Interaction With Open Source. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1671
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

See all articles