First Day on My First Project

As a part of the open source course I’m taking, I just created my first project. It’s called Mastermind – a CLI tool that helps you cheat as a spymaster in the game of Codenames.

For the course, we were supposed to create a command line tool that processes files using a LLM model. Anything goes. A few days ago, I was watching Codenames on YouTube (I like watching party games when I’m bored haha), and the idea just hit me – Linking words together sounds like a perfect job for LLMs. And of course I chose Rust as the language, because why not?

After fumbling my way through GitHub and RustRover, my IDE of choice, I started with handling the arguments. As a Rust newbie and previous C/C++ student, I had the habit of thinking everything step by step. I spent more time than I should on std::env::Args before I discovered the crate clap, which handles arguments for you. Remember, lib.rs is your friend!

use std::path::PathBuf;
use clap::Parser; /// Mastermind - An LLM-powered CLI tool to help you be a better spymaster in Codenames
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args { /// FILE should contain a list of words to link together - the words from your team #[arg(short, long, value_name = "FILE")] link: Option<PathBuf>, /// FILE should contain a list of words to avoid - opponent's words, neutral words, and the assassin word #[arg(short, long, value_name = "FILE")] avoid: Option<PathBuf>,
} fn main() { let args = Args::parse(); println!("{:?}", args);
}
Enter fullscreen mode
Exit fullscreen mode

Here I had my first commit (other than those I made during setup)! It simply takes the arguments and prints them out. It’s simple but it can already handle -h for help and -V for version, thanks to clap!

Demonstrating -h and -V working in my code

I don’t want to make this blog post too long, but the rest of that day was spent in a similar way. I re-familiarize myself with the pattern matching syntax in Rust. I read more about std::fs and implemented the code to read files. I discovered more crates: serde_json for JSON related tasks. reqwest for API calling. dotenv for well… reading .env files

By the end of the day, I already had a working program that outputs the intended outcome… most of the time. I played with different system prompt but still couldn’t get it right. This I might need to find another solution later…

When it works it works… Sometimes it just can’t help but hallucinate…

To some degrees it felt like a day spent in wasted efforts. I kept writing code and rewriting them. But I was happy to learn things along the way. Things like:

  • if let... else gives you clearer syntax than pattern matching. Use it instead when possible
  • Commit more often
  • When method chaining, put each method on a new line
  • Sometimes taking breaks help you solve a problem faster
  • LLMs tend to hallucinate… Even if you give them clear instructions
  • I still have a lot to learn about project structuring
  • I don’t really understand asynchronous programming that much

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top