Skip to content

First take on a complete set of commands and responses #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions moxin-backend/src/fake_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,131 @@ use chrono::NaiveDate;
pub fn get_models() -> Vec<Model> {
let open_hermes_files = vec![
File {
id: "1".to_string(),
name: "openhermes-2.5-mistral-7b.Q2_K.gguf".to_string(),
size: "3.08 GB".to_string(),
quantization: "Q2_K".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec![],
featured: false,
},
File {
id: "2".to_string(),
name: "openhermes-2.5-mistral-7b.Q3_K_S.gguf".to_string(),
size: "3.16 GB".to_string(),
quantization: "Q3_K_S".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec![],
featured: false,
},
File {
id: "3".to_string(),
name: "openhermes-2.5-mistral-7b.Q3_K_M.gguf".to_string(),
size: "3.52 GB".to_string(),
quantization: "Q3_K_M".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec![],
featured: false,
},
File {
id: "4".to_string(),
name: "openhermes-2.5-mistral-7b.Q3_K_L.gguf".to_string(),
size: "3.82 GB".to_string(),
quantization: "Q3_K_M".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec![],
featured: false,
},
File {
id: "5".to_string(),
name: "openhermes-2.5-mistral-7b.Q4_0.gguf".to_string(),
size: "4.11 GB".to_string(),
quantization: "Q4_0".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec![],
featured: false,
},
File {
id: "6".to_string(),
name: "stablelm-zephyr-3b.Q4_K_S.gguf".to_string(),
size: "1.62 GB".to_string(),
quantization: "Q4_K_S".to_string(),
downloaded: true,
downloaded_path: Some("/home/user/.moxin/stablelm-zephyr-3b.Q4_K_S.gguf".to_string()),
tags: vec!["Small & Fast".to_string()],
featured: true,
},
File {
id: "7".to_string(),
name: "stablelm-zephyr-3b.Q6_K.gguf".to_string(),
size: "2.30 GB".to_string(),
quantization: "Q6_K".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec!["Less Compressed".to_string(), "Might be slower".to_string()],
featured: true,
},
];

let nexus_raven_files = vec![
File {
id: "8".to_string(),
name: "nexusraven-v2-13b.Q4_K_S.gguf".to_string(),
size: "7.41 GB".to_string(),
quantization: "Q4_K_S".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec!["Small & Fast".to_string()],
featured: true,
},
File {
id: "9".to_string(),
name: "nexusraven-v2-13b.Q6_K.gguf".to_string(),
size: "10.68 GB".to_string(),
quantization: "Q6_K".to_string(),
downloaded: true,
downloaded_path: Some("/home/user/.moxin/nexusraven-v2-13b.Q6_K.gguf".to_string()),
tags: vec!["Less Compressed".to_string(), "Might be slower".to_string()],
featured: true,
},
];

let stable_lm_files = vec![
File {
id: "10".to_string(),
name: "nexusraven-v2-13b.Q4_K_S.gguf".to_string(),
size: "1.62 GB".to_string(),
quantization: "Q4_K_S".to_string(),
downloaded: true,
downloaded_path: Some("/home/user/.moxin/nexusraven-v2-13b.Q4_K_S.gguf".to_string()),
tags: vec!["Small & Fast".to_string()],
featured: true,
},
File {
id: "11".to_string(),
name: "nexusraven-v2-13b.Q6_K.gguf".to_string(),
size: "2.30 GB".to_string(),
quantization: "Q6_K".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec!["Less Compressed".to_string(), "Might be slower".to_string()],
featured: true,
},
];

let qwen_files = vec![
File {
id: "12".to_string(),
name: "qwen1_5-7b-chat-q5_k_m.gguf".to_string(),
size: "2.30 GB".to_string(),
quantization: "Q5_K_M".to_string(),
downloaded: false,
downloaded_path: None,
tags: vec!["Less Compressed".to_string(), "Might be slower".to_string()],
featured: true,
},
Expand Down
13 changes: 6 additions & 7 deletions moxin-backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
mod fake_data;

use std::sync::mpsc;
use moxin_protocol::protocol::{Command, Response};
use moxin_protocol::protocol::Command;

pub struct Backend {
pub command_sender: mpsc::Sender<Command>,
pub response_receiver: mpsc::Receiver<Response>,
}

impl Default for Backend {
Expand All @@ -17,18 +16,18 @@ impl Default for Backend {
impl Backend {
pub fn new() -> Backend {
let (command_sender, command_receiver) = mpsc::channel();
let (response_sender, response_receiver) = mpsc::channel();

// The backend thread
std::thread::spawn(move || {
loop {
if let Ok(command) = command_receiver.recv() {
match command {
Command::GetFeaturedModels => {
Command::GetFeaturedModels(tx) => {
let models = fake_data::get_models();
response_sender.send(Response::FeaturedModels(models)).unwrap();
tx.send(Ok(models)).unwrap();
//tx.send(Err(anyhow!("Database query failed"))).unwrap();
}
Command::SearchModels(query) => {
Command::SearchModels(query, _tx) => {
println!("Searching for models with query: {}", query);
}
_ => {}
Expand All @@ -37,6 +36,6 @@ impl Backend {
}
});

Backend { command_sender, response_receiver }
Backend { command_sender }
}
}
2 changes: 1 addition & 1 deletion moxin-frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ moxin-protocol = { path = "../moxin-protocol" }
moxin-backend = { path = "../moxin-backend" }
## makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }
makepad-widgets = { path = "../../makepad/widgets", version = "0.6.0" }
chrono = "0.4"
chrono = "0.4"
18 changes: 13 additions & 5 deletions moxin-frontend/src/data/store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use chrono::Utc;
use moxin_protocol::data::{Model, File};
use moxin_protocol::protocol::{Command, Response};
use moxin_protocol::protocol::Command;
use moxin_backend::Backend;
use std::sync::mpsc::channel;

#[derive(Default)]
pub struct Store {
Expand All @@ -20,10 +21,17 @@ impl Store {
backend: Backend::default(),
};

store.backend.command_sender.send(Command::GetFeaturedModels).unwrap();
if let Ok(response) = store.backend.response_receiver.recv() {
if let Response::FeaturedModels(models) = response {
store.models = models;
let (tx, rx) = channel();
store
.backend
.command_sender
.send(Command::GetFeaturedModels(tx))
.unwrap();

if let Ok(response) = rx.recv() {
match response {
Ok(models) => store.models = models,
Err(err) => eprintln!("Error fetching models: {:?}", err),
}
};

Expand Down
2 changes: 2 additions & 0 deletions moxin-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
chrono = "0.4"
serde = { version = "1.0", features = ["derive"] }
22 changes: 21 additions & 1 deletion moxin-protocol/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use chrono::NaiveDate;

pub type FileID = String;
pub type ModelID = String;

#[derive(Debug, Clone, Default)]
pub struct File {
pub id: FileID,
pub name: String,
pub size: String,
pub quantization: String,
pub downloaded: bool,
pub downloaded_path: Option<String>,
pub tags: Vec<String>,
pub featured: bool,
}
Expand All @@ -17,12 +22,27 @@ pub struct Author {
pub description: String,
}

#[derive(Clone, Debug)]
pub enum CompatibilityGuess {
PossiblySupported,
NotSupported,
}

#[derive(Clone, Debug)]
pub struct DownloadedFile {
pub file: File,
pub model: Model,
pub downloaded_at: NaiveDate,
pub compatibility_guess: CompatibilityGuess,
pub information: String,
}

// We're using the HuggingFace identifier as the model ID for now
// We should consider using a different identifier in the future if more
// models sources are added.
#[derive(Debug, Clone, Default)]
pub struct Model {
pub id: String,
pub id: ModelID,
pub name: String,
pub summary: String,
pub size: String,
Expand Down
3 changes: 2 additions & 1 deletion moxin-protocol/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod data;
pub mod protocol;
pub mod protocol;
pub mod open_ai;
Loading