DEV Community

Cover image for Joining ChatCraft.org
Amnish Singh Arora
Amnish Singh Arora

Posted on • Updated on

Joining ChatCraft.org

There is no doubt that Artificial Intelligence is the future, not just of IT, but any domain you could think of.

Just last month, I was chilling in office and one of the testers on my team called me for a quick chit-chat. He sounded worried and was confused if his son should get into programming, as he feared that AI would render programmers obsolete soon. Even though, I tried to convince him that nothing of the sort is happening in the near future, it didn't help much. This goes on to show how much of an impact AI has had on people's lives since last year, and the importance of staying up-to-date with it.

Not long ago, if anyone ever thought of experimenting with AI, they would imagine themselves in the middle of a research lab working on complicated models and algorithms. However, the release of OpenAI API has not only lowered the entry barrier for AI experimentation but has also given rise to lots of innovative tools, making the once seemingly complex world of AI way more approachable.

OpenAI API

This semester, I am taking my second open-source course OSD700 allowing the students to manage an existing open source project and taking it to the next major release.

And this term, we have a super interesting project called ChatCraft. This was a cheerful surprise for me as I've already contributed to this project a few times last term.

These are the posts for more context.

  1. No backing away when hacking away 🎃🚀
  2. Enhancing Sidebar

Table of Contents

 1. What is ChatCraft ⁉️
 2. Setting up the Project ⚙️
       2.1. Generating an SSH key
       2.2. Adding my key to the project
       2.3. Decrypting the KEY 🔐
       2.4. Saving the key in ChatCraft 💬
 3. How do I feel

What is ChatCraft ⁉️

ChatCraft is a developer-oriented GPT client, that extends upon OpenAI's ChatGPT by allowing various additional functionalities like forking from chats like in Github, image and graph generation, customisable response rules, and support for image inputs (coming soon).

My professor David Humphrey is a major contributor for this project and in his words,

ChatCraft is a kind of R&D laboratory for exploring emerging technologies and techniques for working with LLMs. It will allow us to explore and build all kinds of interesting things together, from advanced UX (multi-modal prompting, voice assistants, mobile, etc.) to embedding native code in the web (run non-JS programming languages in the browser via WASM) to cloud computing (data syncing) to working with the latest AI models.

ChatCraft Demo

Apart from all these extra functionalities, the biggest advantage it offers is that its open source, which means you can choose how it works by contributing to the project.

But the most shocking part for me was that even the Creator of Javascript knows ChatCraft.

https://x.com/humphd/status/1743346747382935854?s=46&t=2CRGLNQI0xDqULxhK1Fi6w

Creator of Javascript knows ChatCraft

Setting up the Project ⚙️

Now that I knew I was part of the team and would be contributing to it throughout the term, the first step was to setup the project.

Since I was a previous contributor, I already had it cloned on my machine. However, OpenAI is not free and one thing that was left to do was getting and saving my API key 🔑. The project owner Taras Glek was generous enough to buy it for all the students who would be contributing.

As much as it sounds, this process wasn't as straightforward since the project was using SOPS to manage secrets!

As I was hearing this term for the first time, I had to do some research and I found this article
https://medium.com/@seifeddinerajhi/the-sops-way-the-only-way-to-keep-your-secrets-safe-in-git-4a17e83ef6c6

SOPS

Now that I had some basic idea about what craft SOPS (Secure Operation*s) was, I went through the README file, that specifically focused on working with secrets using **SOPS. With that, I started following the **steps* mentioned.

Generating an SSH key

The first step was to generate an ed25519 - ssh key for my Github account.

This was fairly simple as I had done it multiple times in the past.

ssh-keygen -t ed25519 -C "amnishsingh04@gmail.com"
Enter fullscreen mode Exit fullscreen mode

It gave me some prompts like key location, private key passphrase, and I chose defaults.

ssh-keygen prompts

After the key pair was generated, I copied the public key

ssh key pub

and added it to my github account

Adding ssh key

I skipped adding it to the ssh agent as I has chosen an empty passphrase.

Adding my key to the project

Next, I had to ask the project admins to encrypt and include my key into the project.

Request

And soon, my age encrypted API key was included in .sops.yaml and keys.enc.yaml file.

age key

Decrypting the KEY 🔐

The final step was to decrypt the API key to be used in ChatCraft.

The instructions were simple and included in README.sops.md.

After installing the dependencies,

# install prereqs
go install github.com/getsops/sops/v3/cmd/sops@v3.8.1
go install github.com/Mic92/ssh-to-age/cmd/ssh-to-age@latest
Enter fullscreen mode Exit fullscreen mode
export SOPS_AGE_KEY=scripts/sops_age_key.sh

sops -d sops/keys.enc.yaml
Enter fullscreen mode Exit fullscreen mode

However, this did not work out for me.

Decrypt Fail

After banging some head against the wall, I figured out that export SOPS_AGE_KEY=scripts/sops_age_key.sh wasn't actually returning the result of the script.

The Script

#!/bin/bash

# Source the library script
SCRIPT_DIR=$(dirname "$(realpath "$0")")
source "$SCRIPT_DIR/lib/ssh-to-age.sh"

# Define the path to your private SSH key
SSH_PRIVATE_KEY_PATH="$HOME/.ssh/id_ed25519"

# Find the ssh-to-age binary using the library function
BINARY_PATH=$(find_ssh_to_age_binary)
if [ $? -ne 0 ]; then
    exit 1
fi

# Convert the SSH private key to an age private key using the library function
AGE_PRIVATE_KEY=$(convert_ssh_private_key_to_age "$BINARY_PATH" "$SSH_PRIVATE_KEY_PATH")
if [ $? -ne 0 ]; then
    exit 1
fi

# Output the age private key
echo "$AGE_PRIVATE_KEY"
Enter fullscreen mode Exit fullscreen mode

It looked like it was retrieving my ssh private key

retrieve private key

and echoing the result after converting to an age private key

age key result

I decided to run the script manually and use the returned result for the next steps.

./scripts/sops_age_key.sh

> AGE-xxxxxxxxxxxxxxxxxxxxxxxxxx
Enter fullscreen mode Exit fullscreen mode
export SOPS_AGE_KEY=<The returned key>

sops -d sops/keys.enc.yaml
Enter fullscreen mode Exit fullscreen mode

And finally, I got the key…

Hope you weren't reading till now in hopes I'd accidentally reveal it 😉

Saving the key in ChatCraft 💬

Now that I had the key, it was time to test it in the application.

Pasting api key

After clicking Save, I was routed to the main page with my first chat automatically created.

Main Screen

I tried a couple of test conversations and fortunately, it was working as expected!

ChatCraft Working

How do I feel

In this post, I talked a bit about the importance of AI and how I am getting a chance to explore and experiment with one of the most popular LLMs out there.

Although I am excited to contribute, I am also intimidated at the same time as I feel like venturing into completely uncharted territory. So much so, that my voice cracked up while introducing myself in the first meeting (this has never happened in a long time).

I've never worked with AI before, I've never managed a real project as a team. Seems like there are tonnes of challenges waiting for me on the way, but I am glad I am getting a chance to face them.

Top comments (0)