Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
suryyyansh authored Jun 29, 2024
2 parents 9e80150 + 9355375 commit 57c7d31
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "rag-api-server"
version = "0.6.6"
version = "0.7.0"
edition = "2021"

[dependencies]
endpoints = { version = "=0.8.1" }
chat-prompts = { version = "=0.8.0" }
llama-core = { version = "=0.11.2", features = ["logging"] }
endpoints = { version = "=0.9.0" }
chat-prompts = { version = "=0.8.1" }
llama-core = { version = "=0.11.3", features = ["logging"] }
futures = { version = "0.3.6", default-features = false, features = ["async-await", "std"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
42 changes: 34 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use hyper::{
use llama_core::MetadataBuilder;
use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use std::{net::SocketAddr, path::PathBuf};
use std::{collections::HashMap, net::SocketAddr, path::PathBuf};
use utils::{is_valid_url, qdrant_up, LogLevel};

type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
Expand Down Expand Up @@ -360,13 +360,26 @@ async fn main() -> Result<(), ServerError> {
// log socket address
info!(target: "server_config", "socket_address: {}", addr.to_string());

// get the environment variable `NODE_VERSION`
// Note that this is for satisfying the requirement of `gaianet-node` project.
let node = std::env::var("NODE_VERSION").ok();
if node.is_some() {
// log node version
info!(target: "server_config", "gaianet_node_version: {}", node.as_ref().unwrap());
}

// create server info
let server_info = ServerInfo {
version: env!("CARGO_PKG_VERSION").to_string(),
plugin_version,
port,
node,
server: ApiServer {
ty: "rag".to_string(),
version: env!("CARGO_PKG_VERSION").to_string(),
plugin_version,
port,
},
rag_config,
qdrant_config,
extras: HashMap::new(),
};
SERVER_INFO
.set(server_info)
Expand Down Expand Up @@ -520,18 +533,31 @@ pub(crate) struct ModelConfig {

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ServerInfo {
version: String,
plugin_version: String,
port: String,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "node_version")]
node: Option<String>,
#[serde(rename = "api_server")]
server: ApiServer,
#[serde(flatten)]
rag_config: RagConfig,
#[serde(flatten)]
qdrant_config: QdrantConfig,
extras: HashMap<String, String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ApiServer {
#[serde(rename = "type")]
ty: String,
version: String,
#[serde(rename = "ggml_plugin_version")]
plugin_version: String,
port: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct RagConfig {
pub chat_model: ModelConfig,
pub embedding_model: ModelConfig,
#[serde(rename = "rag_policy")]
pub policy: MergeRagContextPolicy,
}

0 comments on commit 57c7d31

Please sign in to comment.