Skip to content

Commit

Permalink
chatui modelenv config
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Oct 22, 2024
1 parent f4d41b1 commit 6c41818
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
24 changes: 24 additions & 0 deletions src/bin/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::io::Write;
use std::net::TcpListener;

fn main() {
// Bind allows us to create a connection on the port
// and gets it ready to accept connections.
let listener = TcpListener::bind("127.0.0.1:8081").unwrap();

// The listener's accept method waits or 'blocks' until
// we have a connection and then returns a new TcpStream
// that we can read and write data to.
let mut stream = listener.accept().unwrap().0;
let message = "Hello, World!";
let response = format!(
"HTTP/1.1 200 OK\r\n\
Content-Type: text/html; charset=utf-8\r\n\
Content-Length: {}\r\n\
\r\n\
{}",
message.len(),
message
);
let _ = stream.write(response.as_bytes());
}
27 changes: 24 additions & 3 deletions src/images/chat.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::config::Node;
use crate::images::mongo::MongoImage;
use crate::utils::{domain, exposed_ports, host_config};
use crate::utils::{domain, exposed_ports, getenv, host_config};
use anyhow::{Context, Result};
use async_trait::async_trait;
use bollard::{container::Config, Docker};
Expand All @@ -22,7 +22,7 @@ impl ChatImage {
Self {
name: name.to_string(),
version: version.to_string(),
http_port: "8282".to_string(),
http_port: "3000".to_string(),
links: vec![],
host: None,
}
Expand Down Expand Up @@ -65,7 +65,7 @@ fn chat(node: &ChatImage, mongo: &MongoImage) -> Config<String> {
let root_vol = &repo.root_volume;
let ports = vec![node.http_port.clone()];

let env = vec![
let mut env = vec![
format!(
"MONGODB_URL=mongodb://{}:{}",
domain(&mongo.name),
Expand All @@ -76,6 +76,27 @@ fn chat(node: &ChatImage, mongo: &MongoImage) -> Config<String> {
format!("PUBLIC_APP_COLOR=indigo"),
format!("PUBLIC_APP_DESCRIPTION=\"Your knowledge companion.\""),
];
if let Ok(hf_token) = getenv("HF_TOKEN") {
env.push(format!("HF_TOKEN={}", hf_token));
}
let modelsenv = r#"[
{
"name": "Local microsoft/Phi-3-mini-4k-instruct-gguf",
"tokenizer": "microsoft/Phi-3-mini-4k-instruct-gguf",
"preprompt": "",
"parameters": {
"stop": ["<|end|>", "<|endoftext|>", "<|assistant|>"],
"temperature": 0.7,
"max_new_tokens": 1024,
"truncate": 3071
},
"endpoints": [{
"type" : "llamacpp",
"baseURL": "http://host.docker.internal:8080"
}],
},
]`"#;
env.push(modelsenv.to_string());

// let env = vec![format!(
// "MONGODB_URL=mongodb://{}:{}@{}:{}",
Expand Down

0 comments on commit 6c41818

Please sign in to comment.