Skip to content

Commit

Permalink
update env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
hungdv98 committed Jul 17, 2024
1 parent fd64cee commit 3f5b338
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions rust_fortune_teller/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEMINI_API_KEY=changeMe
3 changes: 2 additions & 1 deletion rust_fortune_teller/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/target
.env
7 changes: 7 additions & 0 deletions rust_fortune_teller/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion rust_fortune_teller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
ask_gemini = "0.1.4"
dotenv = "0.15.0"
rand = "0.8.5"
serde = { version = "1.0.204", features = ["derive"] }
tokio = "1.38.1"
tokio = "1.38.1"
10 changes: 7 additions & 3 deletions rust_fortune_teller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use rand;
use rand::seq::SliceRandom;
use ask_gemini::Gemini;
use std::fmt::Write;

const GEMINI_API_KEY: &str = "changeMe";
use dotenv::dotenv;

#[derive(Serialize, Deserialize, Debug)]
pub enum Suit {
Expand Down Expand Up @@ -131,6 +130,11 @@ fn format_reading(reading: &[String]) -> String {

#[tokio::main]
async fn main() {
dotenv().ok();

let gemini_api_key = std::env::var("GEMINI_API_KEY")
.expect("GEMINI_API_KEY must be set");

println!("[INFO] Welcome to Vadar Fortune Teller!");
println!("[INFO] Please let me know your name: ");
let mut username = String::new();
Expand Down Expand Up @@ -169,7 +173,7 @@ async fn main() {

// println!("PROMPTS = {prompt}");

let gemini = Gemini::new(Some(GEMINI_API_KEY), None);
let gemini = Gemini::new(Some(&gemini_api_key), None);
match gemini.ask(&prompt).await {
Ok(response) => {
//println!("[INFO] Signal from the universe: \n {:?}", response);
Expand Down

0 comments on commit 3f5b338

Please sign in to comment.