From 24ef4bcd1655ec34f27dd0458bc9cb0c6ec8182b Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Wed, 23 Oct 2024 10:16:29 -0700 Subject: [PATCH] jamie llama.cpp connection optional --- src/images/jamie.rs | 48 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/images/jamie.rs b/src/images/jamie.rs index 08449110..da4cfd30 100644 --- a/src/images/jamie.rs +++ b/src/images/jamie.rs @@ -43,7 +43,7 @@ impl DockerConfig for JamieImage { async fn make_config(&self, nodes: &Vec, _docker: &Docker) -> Result> { let li = LinkedImages::from_nodes(self.links.clone(), nodes); let mongo = li.find_mongo().context("Chat: No Mongo")?; - let llama = li.find_llama().context("Chat: No Llama")?; + let llama = li.find_llama(); Ok(jamie(self, &mongo, &llama)) } } @@ -58,7 +58,7 @@ impl DockerHubImage for JamieImage { } } -fn jamie(node: &JamieImage, mongo: &MongoImage, llama: &LlamaImage) -> Config { +fn jamie(node: &JamieImage, mongo: &MongoImage, llama_opt: &Option) -> Config { let name = node.name.clone(); let repo = node.repo(); let image = format!("{}/{}", repo.org, repo.repo); @@ -81,27 +81,29 @@ fn jamie(node: &JamieImage, mongo: &MongoImage, llama: &LlamaImage) -> Config", "<|endoftext|>", "<|assistant|>"], - "temperature": 0.7, - "max_new_tokens": 1024, - "truncate": 3071 - }}, - "endpoints": [{{ - "type" : "llamacpp", - "baseURL": "http://{}:{}" - }}], - }}, - ]`"#, - domain(&llama.name), - llama.port - ); - env.push(format!("DOTENV_LOCAL={}", dotenvlocal)); + if let Some(llama) = llama_opt { + let dotenvlocal = format!( + r#"MODELS=`[ + {{ + "name": "Local Jamie", + "preprompt": "", + "parameters": {{ + "stop": ["<|end|>", "<|endoftext|>", "<|assistant|>"], + "temperature": 0.7, + "max_new_tokens": 1024, + "truncate": 3071 + }}, + "endpoints": [{{ + "type" : "llamacpp", + "baseURL": "http://{}:{}" + }}], + }}, +]`"#, + domain(&llama.name), + llama.port + ); + env.push(format!("DOTENV_LOCAL={}", dotenvlocal)); + } // let env = vec![format!( // "MONGODB_URL=mongodb://{}:{}@{}:{}",