|
@@ -1,18 +1,23 @@
|
|
#[cfg(feature = "mkl")]
|
|
#[cfg(feature = "mkl")]
|
|
extern crate intel_mkl_src;
|
|
extern crate intel_mkl_src;
|
|
|
|
+
|
|
|
|
+#[macro_use]
|
|
|
|
+extern crate log;
|
|
|
|
+
|
|
mod args;
|
|
mod args;
|
|
mod database;
|
|
mod database;
|
|
mod embed;
|
|
mod embed;
|
|
mod server;
|
|
mod server;
|
|
mod vector_db;
|
|
mod vector_db;
|
|
|
|
|
|
-use actix_web::{web, App, HttpServer};
|
|
|
|
|
|
+use actix_web::{middleware, web, App, HttpServer};
|
|
use args::Args;
|
|
use args::Args;
|
|
use clap::Parser;
|
|
use clap::Parser;
|
|
use embed::encoder;
|
|
use embed::encoder;
|
|
|
|
|
|
#[actix_web::main]
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
+ env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug"));
|
|
let args = Args::parse();
|
|
let args = Args::parse();
|
|
|
|
|
|
// [BEGIN] INIT
|
|
// [BEGIN] INIT
|
|
@@ -21,21 +26,27 @@ async fn main() -> std::io::Result<()> {
|
|
let (model, tokenizer) = args.build_model_and_tokenizer().unwrap();
|
|
let (model, tokenizer) = args.build_model_and_tokenizer().unwrap();
|
|
let enc = encoder::Encoder::new(model, tokenizer);
|
|
let enc = encoder::Encoder::new(model, tokenizer);
|
|
let app_data_encoder = web::Data::new(enc);
|
|
let app_data_encoder = web::Data::new(enc);
|
|
|
|
+ info!("MODEL loaded");
|
|
|
|
|
|
// DATABSE
|
|
// DATABSE
|
|
let database = database::new_connection_pool();
|
|
let database = database::new_connection_pool();
|
|
let app_data_database = web::Data::new(database);
|
|
let app_data_database = web::Data::new(database);
|
|
|
|
+ info!("DATABASE loaded");
|
|
|
|
|
|
// VECTOR DATABASE
|
|
// VECTOR DATABASE
|
|
let vector = vector_db::start();
|
|
let vector = vector_db::start();
|
|
let app_data_vector = web::Data::new(vector);
|
|
let app_data_vector = web::Data::new(vector);
|
|
|
|
+ info!("VECTOR DATABASE loaded");
|
|
|
|
|
|
// [END] INIT
|
|
// [END] INIT
|
|
args.terminate_if_ci();
|
|
args.terminate_if_ci();
|
|
|
|
|
|
- println!("Listen on 0.0.0.0:8080");
|
|
|
|
|
|
+ info!("Listen on 0.0.0.0:8080");
|
|
|
|
+
|
|
let result = HttpServer::new(move || {
|
|
let result = HttpServer::new(move || {
|
|
App::new()
|
|
App::new()
|
|
|
|
+ .wrap(middleware::Logger::default())
|
|
|
|
+ .wrap(middleware::Compress::default())
|
|
.app_data(app_data_encoder.clone())
|
|
.app_data(app_data_encoder.clone())
|
|
.app_data(app_data_database.clone())
|
|
.app_data(app_data_database.clone())
|
|
.app_data(app_data_vector.clone())
|
|
.app_data(app_data_vector.clone())
|
|
@@ -45,6 +56,6 @@ async fn main() -> std::io::Result<()> {
|
|
.bind(("0.0.0.0", 8080))?
|
|
.bind(("0.0.0.0", 8080))?
|
|
.run()
|
|
.run()
|
|
.await;
|
|
.await;
|
|
- println!("Server Terminated. Byebye :-)");
|
|
|
|
|
|
+ info!("Server Terminated. Byebye :-)");
|
|
result
|
|
result
|
|
}
|
|
}
|