Skip to content

youpele52/clai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clai

this is a simple command line based program built using Rust and rust-genai.

by default, the program uses gemini AI model, but this can be changed using the set command in how to run.

installation

  • install rust
  • navigate to the project's main folder to build the program using
cargo build --release

to use the program already, you can jump to how to run.

run everywhere

if you want to run the program anywhere in the terminal rather than being tied to the program's main folder, you will have to add the program's binary's directory to your PATH.

  • the binary can be found in clai/target/release, however, after you get to /release folder, you'll need to get the full/release/path using
pwd
  • next, is to run the following commands. Don't forget to replace .zshrc with .bashrc if you are using bash
echo 'export PATH="$PATH:/path/to/your/binary/directory"' >> ~/.zshrc   &&

source ~/.zshrc

  • to use the program, just like it is in how to run, first export your key, however to make queries or any other commands, replace 'cargo run' with 'clai'.

eg

clai q "your query"

how to run

navigate to the project's main folder and run these commands in your terminal

  • set the AI model
cargo run set "ai-model"
export GEMINI_API_KEY="your_api_key"

if you are using openai, after setting the model using the above command, you can export the key like so

export OPENAI_API_KEY="your_api_key"
  • then run this to make your query
cargo run q "your query"
  • by default the set constraint is "Answer with at most five sentences.". Since, it is a terminal based AI program, it's best to keep answers concise. However to change this by adding one more argument. Like so:
cargo run q "your query" -c "your custom constraint"

state management

conversations between the user and the AI is saved locally and is managed using Serde JSON. The saved conversation, is only used to give the AI context about the previous questions. To delete the saved conversations use the command below.

cargo run d

About

Test riding genai https://crates.io/crates/genai

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages