mirror of
https://github.com/geoffsee/predict-otron-9001.git
synced 2025-09-08 22:46:44 +00:00
fix format error
This commit is contained in:
14
Cargo.lock
generated
14
Cargo.lock
generated
@@ -893,7 +893,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cli"
|
name = "cli"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codee"
|
name = "codee"
|
||||||
@@ -1471,7 +1471,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embeddings-engine"
|
name = "embeddings-engine"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-openai",
|
"async-openai",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -2093,7 +2093,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gemma-runner"
|
name = "gemma-runner"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"candle-core 0.9.1 (git+https://github.com/huggingface/candle.git)",
|
"candle-core 0.9.1 (git+https://github.com/huggingface/candle.git)",
|
||||||
@@ -2274,7 +2274,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "helm-chart-tool"
|
name = "helm-chart-tool"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -2684,7 +2684,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inference-engine"
|
name = "inference-engine"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph",
|
"ab_glyph",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -3177,7 +3177,7 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "llama-runner"
|
name = "llama-runner"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"candle-core 0.9.1 (git+https://github.com/huggingface/candle.git)",
|
"candle-core 0.9.1 (git+https://github.com/huggingface/candle.git)",
|
||||||
@@ -4056,7 +4056,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "predict-otron-9000"
|
name = "predict-otron-9000"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"chat-ui",
|
"chat-ui",
|
||||||
|
@@ -29,7 +29,7 @@ cd crates/chat-ui
|
|||||||
This starts the development server on port 8788 with auto-reload capabilities.
|
This starts the development server on port 8788 with auto-reload capabilities.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
1. Start the predict-otron-9000 server: `./scripts/run_server.sh`
|
1. Start the predict-otron-9000 server: `./scripts/run.sh`
|
||||||
2. Start the chat-ui: `cd crates/chat-ui && ./run.sh`
|
2. Start the chat-ui: `cd crates/chat-ui && ./run.sh`
|
||||||
3. Navigate to `http://localhost:8788`
|
3. Navigate to `http://localhost:8788`
|
||||||
4. Start chatting with your AI models!
|
4. Start chatting with your AI models!
|
||||||
|
@@ -12,7 +12,6 @@ pub struct AppConfig {
|
|||||||
|
|
||||||
impl Default for AppConfig {
|
impl Default for AppConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|
||||||
let conf = get_configuration(Some(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml")))
|
let conf = get_configuration(Some(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml")))
|
||||||
.expect("failed to read config");
|
.expect("failed to read config");
|
||||||
|
|
||||||
@@ -41,6 +40,7 @@ pub fn create_router(leptos_options: LeptosOptions) -> Router {
|
|||||||
.with_state(leptos_options)
|
.with_state(leptos_options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use gloo_net::http::Request;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
|
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
|
||||||
use leptos_router::{
|
use leptos_router::{
|
||||||
@@ -48,7 +48,6 @@ use leptos_router::{
|
|||||||
StaticSegment,
|
StaticSegment,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use gloo_net::http::Request;
|
|
||||||
use web_sys::console;
|
use web_sys::console;
|
||||||
// Remove spawn_local import as we'll use different approach
|
// Remove spawn_local import as we'll use different approach
|
||||||
|
|
||||||
@@ -122,7 +121,10 @@ pub async fn fetch_models() -> Result<Vec<ModelInfo>, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API client function to send chat completion requests
|
// API client function to send chat completion requests
|
||||||
pub async fn send_chat_completion(messages: Vec<ChatMessage>, model: String) -> Result<String, String> {
|
pub async fn send_chat_completion(
|
||||||
|
messages: Vec<ChatMessage>,
|
||||||
|
model: String,
|
||||||
|
) -> Result<String, String> {
|
||||||
let request = ChatRequest {
|
let request = ChatRequest {
|
||||||
model,
|
model,
|
||||||
messages,
|
messages,
|
||||||
@@ -206,20 +208,20 @@ pub fn App() -> impl IntoView {
|
|||||||
fn ChatPage() -> impl IntoView {
|
fn ChatPage() -> impl IntoView {
|
||||||
// State for conversation messages
|
// State for conversation messages
|
||||||
let messages = RwSignal::new(Vec::<ChatMessage>::new());
|
let messages = RwSignal::new(Vec::<ChatMessage>::new());
|
||||||
|
|
||||||
// State for current user input
|
// State for current user input
|
||||||
let input_text = RwSignal::new(String::new());
|
let input_text = RwSignal::new(String::new());
|
||||||
|
|
||||||
// State for loading indicator
|
// State for loading indicator
|
||||||
let is_loading = RwSignal::new(false);
|
let is_loading = RwSignal::new(false);
|
||||||
|
|
||||||
// State for error messages
|
// State for error messages
|
||||||
let error_message = RwSignal::new(Option::<String>::None);
|
let error_message = RwSignal::new(Option::<String>::None);
|
||||||
|
|
||||||
// State for available models and selected model
|
// State for available models and selected model
|
||||||
let available_models = RwSignal::new(Vec::<ModelInfo>::new());
|
let available_models = RwSignal::new(Vec::<ModelInfo>::new());
|
||||||
let selected_model = RwSignal::new(String::from("gemma-3-1b-it")); // Default model
|
let selected_model = RwSignal::new(String::from("gemma-3-1b-it")); // Default model
|
||||||
|
|
||||||
// Client-side only: Fetch models on component mount
|
// Client-side only: Fetch models on component mount
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
@@ -249,7 +251,7 @@ fn ChatPage() -> impl IntoView {
|
|||||||
role: "user".to_string(),
|
role: "user".to_string(),
|
||||||
content: user_input.clone(),
|
content: user_input.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
messages.update(|msgs| msgs.push(user_message.clone()));
|
messages.update(|msgs| msgs.push(user_message.clone()));
|
||||||
input_text.set(String::new());
|
input_text.set(String::new());
|
||||||
is_loading.set(true);
|
is_loading.set(true);
|
||||||
@@ -259,11 +261,11 @@ fn ChatPage() -> impl IntoView {
|
|||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
use leptos::task::spawn_local;
|
use leptos::task::spawn_local;
|
||||||
|
|
||||||
// Prepare messages for API call
|
// Prepare messages for API call
|
||||||
let current_messages = messages.get();
|
let current_messages = messages.get();
|
||||||
let current_model = selected_model.get();
|
let current_model = selected_model.get();
|
||||||
|
|
||||||
// Spawn async task to call API
|
// Spawn async task to call API
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
match send_chat_completion(current_messages, current_model).await {
|
match send_chat_completion(current_messages, current_model).await {
|
||||||
@@ -307,7 +309,7 @@ fn ChatPage() -> impl IntoView {
|
|||||||
<h1>"Predict-Otron-9000 Chat"</h1>
|
<h1>"Predict-Otron-9000 Chat"</h1>
|
||||||
<div class="model-selector">
|
<div class="model-selector">
|
||||||
<label for="model-select">"Model:"</label>
|
<label for="model-select">"Model:"</label>
|
||||||
<select
|
<select
|
||||||
id="model-select"
|
id="model-select"
|
||||||
prop:value=move || selected_model.get()
|
prop:value=move || selected_model.get()
|
||||||
on:change=move |ev| {
|
on:change=move |ev| {
|
||||||
@@ -329,7 +331,7 @@ fn ChatPage() -> impl IntoView {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="chat-messages">
|
<div class="chat-messages">
|
||||||
<For
|
<For
|
||||||
each=move || messages.get().into_iter().enumerate()
|
each=move || messages.get().into_iter().enumerate()
|
||||||
@@ -344,7 +346,7 @@ fn ChatPage() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{move || {
|
{move || {
|
||||||
if is_loading.get() {
|
if is_loading.get() {
|
||||||
view! {
|
view! {
|
||||||
@@ -379,7 +381,7 @@ fn ChatPage() -> impl IntoView {
|
|||||||
on:keydown=on_key_down
|
on:keydown=on_key_down
|
||||||
class:disabled=move || is_loading.get()
|
class:disabled=move || is_loading.get()
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
on:click=on_button_click
|
on:click=on_button_click
|
||||||
class:disabled=move || is_loading.get() || input_text.get().trim().is_empty()
|
class:disabled=move || is_loading.get() || input_text.get().trim().is_empty()
|
||||||
>
|
>
|
||||||
|
@@ -1,14 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
|
use chat_ui::app::*;
|
||||||
use leptos::logging::log;
|
use leptos::logging::log;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_axum::{generate_route_list, LeptosRoutes};
|
use leptos_axum::{generate_route_list, LeptosRoutes};
|
||||||
use chat_ui::app::*;
|
|
||||||
|
|
||||||
let conf = get_configuration(None).expect("failed to read config");
|
let conf = get_configuration(None).expect("failed to read config");
|
||||||
let addr = conf.leptos_options.site_addr;
|
let addr = conf.leptos_options.site_addr;
|
||||||
@@ -26,4 +23,4 @@ async fn main() {
|
|||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
// no client-side main function
|
// no client-side main function
|
||||||
}
|
}
|
||||||
|
@@ -4,27 +4,27 @@ mod middleware;
|
|||||||
mod standalone_mode;
|
mod standalone_mode;
|
||||||
|
|
||||||
use crate::standalone_mode::create_standalone_router;
|
use crate::standalone_mode::create_standalone_router;
|
||||||
|
use axum::handler::Handler;
|
||||||
|
use axum::http::StatusCode as AxumStatusCode;
|
||||||
|
use axum::http::header;
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::routing::get;
|
use axum::routing::get;
|
||||||
use axum::{Router, http::Uri, response::Html, serve, ServiceExt};
|
use axum::{Router, ServiceExt, http::Uri, response::Html, serve};
|
||||||
use config::ServerConfig;
|
use config::ServerConfig;
|
||||||
use ha_mode::create_ha_router;
|
use ha_mode::create_ha_router;
|
||||||
use inference_engine::AppState;
|
use inference_engine::AppState;
|
||||||
|
use log::info;
|
||||||
use middleware::{MetricsLayer, MetricsLoggerFuture, MetricsStore};
|
use middleware::{MetricsLayer, MetricsLoggerFuture, MetricsStore};
|
||||||
|
use mime_guess::from_path;
|
||||||
use rust_embed::Embed;
|
use rust_embed::Embed;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Component::ParentDir;
|
use std::path::Component::ParentDir;
|
||||||
use axum::handler::Handler;
|
|
||||||
use axum::http::header;
|
|
||||||
use mime_guess::from_path;
|
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tower::MakeService;
|
use tower::MakeService;
|
||||||
use tower_http::classify::ServerErrorsFailureClass::StatusCode;
|
use tower_http::classify::ServerErrorsFailureClass::StatusCode;
|
||||||
use tower_http::cors::{Any, CorsLayer};
|
use tower_http::cors::{Any, CorsLayer};
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
use axum::http::{StatusCode as AxumStatusCode };
|
|
||||||
use log::info;
|
|
||||||
|
|
||||||
#[derive(Embed)]
|
#[derive(Embed)]
|
||||||
#[folder = "../../target/site"]
|
#[folder = "../../target/site"]
|
||||||
@@ -34,7 +34,6 @@ use log::info;
|
|||||||
#[include = "*.ico"]
|
#[include = "*.ico"]
|
||||||
struct Asset;
|
struct Asset;
|
||||||
|
|
||||||
|
|
||||||
async fn static_handler(uri: Uri) -> axum::response::Response {
|
async fn static_handler(uri: Uri) -> axum::response::Response {
|
||||||
// Strip the leading `/`
|
// Strip the leading `/`
|
||||||
let path = uri.path().trim_start_matches('/');
|
let path = uri.path().trim_start_matches('/');
|
||||||
@@ -49,18 +48,12 @@ async fn static_handler(uri: Uri) -> axum::response::Response {
|
|||||||
let body = content.data.into_owned();
|
let body = content.data.into_owned();
|
||||||
let mime = from_path(path).first_or_octet_stream();
|
let mime = from_path(path).first_or_octet_stream();
|
||||||
|
|
||||||
(
|
([(header::CONTENT_TYPE, mime.as_ref())], body).into_response()
|
||||||
[(header::CONTENT_TYPE, mime.as_ref())],
|
|
||||||
body,
|
|
||||||
)
|
|
||||||
.into_response()
|
|
||||||
}
|
}
|
||||||
None => (AxumStatusCode::NOT_FOUND, "404 Not Found").into_response(),
|
None => (AxumStatusCode::NOT_FOUND, "404 Not Found").into_response(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Initialize tracing
|
// Initialize tracing
|
||||||
@@ -123,7 +116,6 @@ async fn main() {
|
|||||||
// Create the leptos router for the web frontend
|
// Create the leptos router for the web frontend
|
||||||
let leptos_router = chat_ui::app::create_router(leptos_config.config.leptos_options);
|
let leptos_router = chat_ui::app::create_router(leptos_config.config.leptos_options);
|
||||||
|
|
||||||
|
|
||||||
// Merge the service router with base routes and add middleware layers
|
// Merge the service router with base routes and add middleware layers
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/pkg/{*path}", get(static_handler))
|
.route("/pkg/{*path}", get(static_handler))
|
||||||
|
Reference in New Issue
Block a user