Skip to content

Commit

Permalink
GE
Browse files Browse the repository at this point in the history
  • Loading branch information
danielclough committed Jul 31, 2024
1 parent 0a0b3d2 commit 403f950
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 21 deletions.
36 changes: 25 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,40 @@ help:
@echo "make stop\n\tKill running processes."

init:
# apt-get install
@sudo apt-get update && sudo apt-get install -y gcc build-essential libssl-dev pkg-config nvidia-cuda-toolkit;
# install rust if not available
@if ! command -v cargo; then \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \
# Install required packages
ifeq ($(shell uname),Darwin)
@if ! command -v brew &> /dev/null; then \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
fi
@brew update && brew install openssl pkg-config
else
@sudo apt-get update
@sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
@sudo apt-get install -y gcc pkg-config nvidia-cuda-toolkit
endif

# Install Rust if not available
@if ! command -v cargo &> /dev/null; then \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
. "$$HOME/.cargo/env"; \
fi
# install wasm target if not available
@if ! command -v rustup target list | grep "wasm32-unknown-unknown (installed)"; then \

# Install wasm target if not available
@if ! rustup target list | grep -q "wasm32-unknown-unknown (installed)"; then \
rustup target add wasm32-unknown-unknown; \
fi
# install trunk if not available
@if ! command -v trunk; then \

# Install trunk if not available
@if ! command -v trunk &> /dev/null; then \
cargo install trunk; \
fi
# install cargo-watch if not available
@if ! command -v cargo-watch; then \

# Install cargo-watch if not available
@if ! command -v cargo-watch &> /dev/null; then \
cargo install cargo-watch; \
fi


.PHONY: docker
docker:
@cd docker && sh docker-build.sh
Expand Down
6 changes: 5 additions & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hf-hub = "0.3.2"
regex = "1.10.2"
serde = { version = "1.0.192", features = ["derive"] }
serde_yaml = "0.9.27"
tokenizers = "0.15"
tokenizers = "0.19"
tokio = { version = "1.34.0", features = ["full"] }
tracing = "0.1.40"
intel-mkl-src = { version = "0.8.1", features = ["mkl-static-lp64-iomp"] }
Expand All @@ -37,3 +37,7 @@ candle-core = { path = "../../candle/candle-core", features = ["cuda"] }
[target.x86_64-apple-darwin.dependencies]
candle-transformers = { path = "../../candle/candle-transformers" }
candle-core = { path = "../../candle/candle-core" }

[target.aarch64-apple-darwin.dependencies]
candle-transformers = { path = "../../candle/candle-transformers", features = ["metal"] }
candle-core = { path = "../../candle/candle-core", features = ["metal"] }
3 changes: 2 additions & 1 deletion backend/src/llm/load_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ impl LoadModel {
pub fn load_current_args() -> LoadModel {
// Tauri config dir
let config_path = config_file_path("config_model.yaml");
println!("{:#?}",config_path);
let config_model_string = std::fs::read_to_string(config_path);

if config_model_string.is_ok() {
println!("Loading '$HOME/.config/fireside-chat/config_model.yaml'");
let unwrapped = &config_model_string.unwrap();
serde_yaml::from_str(unwrapped.as_str()).unwrap()
} else {
Expand Down Expand Up @@ -272,6 +272,7 @@ impl LoadModel {
}
_ => MistralConfig::config_7b_v0_1(args.use_flash_attn),
};
// println!("{:?}",config);
if args.quantized {
let vb = candle_transformers::quantized_var_builder::VarBuilder::from_gguf(
&filenames[0],
Expand Down
2 changes: 2 additions & 0 deletions backend/src/server/rest/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub async fn get_inference(
) -> Result<Json<InferenceArgsForJson>, StatusCode> {
let args = state.inference_args.lock().expect("lock state");

println!("{:#?}",args);

let role = match &args.role {
Some(r) => r.to_string(),
None => String::new(),
Expand Down
1 change: 1 addition & 0 deletions backend/src/server/rest/model_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn get_model_list(Path(q_lvl): Path<String>) -> Result<Json<ModelDLLis
let mut safetensors = false;
let mut bin = false;
let cache_file_path = cache_file_path(&repo_id_path);
println!("{:?}",cache_file_path);
if cache_file_path.is_dir() {
let q_lvl = if q_lvl.as_str() == "NoModel" {
ModelArgs::default().q_lvl
Expand Down
19 changes: 17 additions & 2 deletions backend/src/utilities/cache_path.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
use std::path::PathBuf;
use std::{env, path::PathBuf};

use tauri::{api::path::app_cache_dir, Config};

pub fn cache_file_path(slug: &str) -> PathBuf {
let cache_dir = app_cache_dir(&Config::default()).expect("load huggingface/hub cache dir");
let cache_dir = match env::var_os("USER") {
Some(value) => {

if cfg!(target_os = "macos") {
PathBuf::from(format!("/Users/{}/.cache", value.to_string_lossy()))
} else if cfg!(target_os = "linux") {
PathBuf::from(format!("/home/{}/.cache", value.to_string_lossy()))
} else {
println!("\n\tUnspported OS!!!\n");
PathBuf::from(format!("/home/{}/.cache", value.to_string_lossy()))
}
},
None => app_cache_dir(&Config::default()).expect("load huggingface/hub cache dir"),
};

let path = format!("huggingface/hub/{}", slug);

cache_dir.join(path)
}
26 changes: 22 additions & 4 deletions backend/src/utilities/config_path.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
use std::path::PathBuf;
use std::{env, path::PathBuf};

use tauri::{api::path::app_config_dir, Config};

pub fn config_file_path(slug: &str) -> PathBuf {
let config_dir = app_config_dir(&Config::default()).expect("load tauri config");
let config_dir = app_config_file_path();
let fireside = "fireside-chat".to_string();
let config_dir_path = config_dir.join(fireside);
_ = std::fs::create_dir_all(&config_dir_path);
config_dir_path.join(slug)
}

pub fn config_file_dir() -> PathBuf {
let config_dir = app_config_dir(&Config::default()).expect("load tauri config");
let config_dir = app_config_file_path();
let fireside = "fireside-chat".to_string();
let path = config_dir.join(fireside);
_ = std::fs::create_dir_all(&path);
path
}

pub fn context_file_dir() -> PathBuf {
let config_dir = app_config_dir(&Config::default()).expect("load tauri config");
let config_dir = app_config_file_path();
let path = "fireside-chat/context".to_string();
let path = config_dir.join(path);
_ = std::fs::create_dir_all(&path);
path
}


pub fn app_config_file_path() -> PathBuf {
match env::var_os("USER") {
Some(value) => {

if cfg!(target_os = "macos") {
PathBuf::from(format!("/Users/{}/.config", value.to_string_lossy()))
} else if cfg!(target_os = "linux") {
PathBuf::from(format!("/home/{}/.config", value.to_string_lossy()))
} else {
println!("\n\tUnspported OS!!!\n");
app_config_dir(&Config::default()).expect("load huggingface/hub cache dir")
}
},
None => app_config_dir(&Config::default()).expect("load huggingface/hub cache dir"),
}
}
2 changes: 1 addition & 1 deletion frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license-file = "LICENSE"
[dependencies]
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
leptos = { version = "0.6", features = ["csr"] }
leptos = { version = "0.6.13", features = ["csr"] }
leptos-use = { version = "0.10", features = ["serde"] }
log = "0.4.20"
web-sys = "0.3.65"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn ModelListGrid(
create_signal::<bool>(tags_all.get().len() == tags_enabled.get().len());

view! {
<Grid style="padding:1rem;" spacing=Size::Em(0.6)>
<Grid style="padding:1rem;" gap=Size::Em(0.6) >
<H1 style="width:100%;padding:0.25rem;text-align:center;box-shadow:2px 2px 8px #000;">
"Model List"
</H1>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/functions/rest/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub async fn get_user_by_name(name: String, database_url: String) -> UserForJson
let route: String = format!("user/name/{}", name);
let path = get_database_path(&route, database_url);

println!("{}",path);

let default = UserForJson {
id: 0,
name: "".to_string(),
Expand Down

0 comments on commit 403f950

Please sign in to comment.