Skip to content

Commit

Permalink
List aliases in Ollama help text
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed Apr 30, 2024
1 parent 5e273cd commit 1bbdddc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const CONST_ASSIGNMENTS: [(&str, &str); 9] = [
("CLAUDE_HAIKU", "claude-3-haiku-20240307"),
];

const GROQ_MODEL_MAPPING_SRC: [(&str, &str); 11] = [
const GROQ_MODEL_MAPPING_SRC: [(&str, &str); 12] = [
("llama3", "GROQ_LLAMA"),
("llama", "GROQ_LLAMA"),
("ll", "GROQ_LLAMA"),
Expand All @@ -26,16 +26,18 @@ const GROQ_MODEL_MAPPING_SRC: [(&str, &str); 11] = [
("ll-70", "GROQ_LLAMA_70"),
("ll70", "GROQ_LLAMA_70"),
("mixtral", "GROQ_MIXTRAL"),
("mix", "GROQ_MIXTRAL"),
("mi", "GROQ_MIXTRAL"),
("gemma", "GROQ_GEMMA"),
("ge", "GROQ_GEMMA"),
];

const OLLAMA_MODEL_MAPPING_SRC: [(&str, &str); 10] = [
const OLLAMA_MODEL_MAPPING_SRC: [(&str, &str); 11] = [
("llama", "llama3"),
("ll", "llama3"),
("llama2", "llama2"),
("ll2", "llama2"),
("mix", "mixtral"),
("mi", "mixtral"),
("mis", "mistral"),
("ge", "gemma"),
Expand Down
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::io::stdin;
use std::io::{read_to_string, IsTerminal};

use cai::{
exec_tool, groq_models_pretty, submit_prompt, Model, Provider, CLAUDE_HAIKU,
CLAUDE_OPUS, CLAUDE_SONNET, GROQ_LLAMA, GROQ_MIXTRAL, OPENAI_GPT,
OPENAI_GPT_TURBO,
exec_tool, groq_models_pretty, ollama_models_pretty, submit_prompt, Model,
Provider, CLAUDE_HAIKU, CLAUDE_OPUS, CLAUDE_SONNET, GROQ_LLAMA, GROQ_MIXTRAL,
OPENAI_GPT, OPENAI_GPT_TURBO,
};
use clap::{builder::styling, crate_version, Parser, Subcommand};
use color_print::cformat;
Expand Down Expand Up @@ -101,8 +101,11 @@ enum Commands {
/// Ollama server hosted at http://localhost:11434
#[clap(visible_alias = "ol")]
Ollama {
/// The model to use from the locally installed ones.
/// Get new ones from https://ollama.com/library.
#[clap(help = ollama_models_pretty!(
"The model to use from the locally installed ones.\n\
Get new ones from https://ollama.com/library.\n\
Following aliases are available:"
))]
model: String,
/// The prompt to send to the AI model
prompt: Vec<String>,
Expand Down
8 changes: 8 additions & 0 deletions src_templates/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ fn get_ollama_model(model_id: &str) -> &str {
pub const OLLAMA_MODELS_PRETTY: &str =
// This will be replaced by build.rs:
"{ollama_models_pretty}";

#[macro_export]
macro_rules! ollama_models_pretty {
($prefix: expr) => {
// This will be replaced by build.rs
concat!($prefix, "\n", "{ollama_models_pretty}")
};
}

0 comments on commit 1bbdddc

Please sign in to comment.