-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Project structure refactoring (#42)
* refactor(project): Save point of project and project structure refactoring * fix(tests): Fixed tests after all changes * fix(tests): Fixed tests after all changes * chore(docs): Updated README.md file
- Loading branch information
1 parent
a28553e
commit 7016fe9
Showing
52 changed files
with
2,298 additions
and
2,602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
SERVICE_RUN_MODE: 'production' | ||
SERVICE_WORKERS_NUM: 6 | ||
SERVICE_ENABLE_TLS: 'false' | ||
SERVICE_ALLOWED_CORS: '*' | ||
SERVICE_RUN_MODE=production | ||
SERVICE_WORKERS_NUM=6 | ||
SERVICE_ENABLE_TLS=false | ||
SERVICE_ALLOWED_CORS=* | ||
|
||
EMBEDDINGS_ENABLE_TLS: 'false' | ||
EMBEDDINGS_ENABLE_TLS=false | ||
|
||
ELASTIC_USERNAME: 'elastic' | ||
ELASTIC_PASSWORD: 'elastic' | ||
ELASTIC_ENABLE_TLS: 'false' | ||
ELASTIC_USERNAME=elastic | ||
ELASTIC_PASSWORD=elastic | ||
ELASTIC_ENABLE_TLS=false | ||
|
||
REDIS_ROOT_PASSWORD: 'cacher' | ||
REDIS_CLIENT_USERNAME: 'cacher' | ||
REDIS_CLIENT_PASSWORD: 'cacher' | ||
REDIS_DATA_EXPIRED: 3600 | ||
REDIS_ROOT_PASSWORD=redis | ||
REDIS_CLIENT_USERNAME=redis | ||
REDIS_CLIENT_PASSWORD=redis | ||
REDIS_DATA_EXPIRED=3600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ expired = 3600 | |
address = "localhost:8085" | ||
is_truncate = "false" | ||
is_normalize = "false" | ||
enabled_tls = "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ expired = 3600 | |
address = "embeddings:8085" | ||
is_truncate = "false" | ||
is_normalize = "false" | ||
enabled_tls = "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "elschema" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
derive_builder = "^0.20" | ||
serde = "^1.0" | ||
serde_derive = "^1.0" | ||
serde_json = "^1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
use serde::Serializer; | ||
use serde_derive::Serialize; | ||
|
||
#[derive(Serialize)] | ||
pub struct EnabledFlag { | ||
enabled: bool, | ||
} | ||
|
||
#[allow(dead_code)] | ||
impl EnabledFlag { | ||
pub fn new(is_enabled: bool) -> Self { | ||
EnabledFlag { | ||
enabled: is_enabled, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct SettingsSchema { | ||
number_of_shards: i32, | ||
number_of_replicas: i32, | ||
} | ||
|
||
impl Default for SettingsSchema { | ||
fn default() -> Self { | ||
SettingsSchema { | ||
number_of_shards: 1, | ||
number_of_replicas: 1, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Default)] | ||
pub enum FieldType { | ||
Date, | ||
DenseVector, | ||
Integer, | ||
Object, | ||
Nested, | ||
#[default] | ||
Keyword, | ||
Text, | ||
Boolean, | ||
} | ||
|
||
impl serde::Serialize for FieldType { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
let field_type_str = match self { | ||
FieldType::Date => "date", | ||
FieldType::Text => "text", | ||
FieldType::Object => "object", | ||
FieldType::Nested => "nested", | ||
FieldType::Boolean => "boolean", | ||
FieldType::Integer => "integer", | ||
FieldType::Keyword => "keyword", | ||
FieldType::DenseVector => "dense_vector", | ||
}; | ||
|
||
serializer.collect_str(field_type_str) | ||
} | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct SchemaFieldType { | ||
#[serde(rename(serialize = "type"))] | ||
field_type: FieldType, | ||
} | ||
|
||
impl SchemaFieldType { | ||
pub fn new(field_type: FieldType) -> Self { | ||
SchemaFieldType { field_type } | ||
} | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct AsDateField { | ||
#[serde(rename(serialize = "type"))] | ||
field_type: FieldType, | ||
ignore_malformed: bool, | ||
} | ||
|
||
impl Default for AsDateField { | ||
fn default() -> Self { | ||
AsDateField { | ||
field_type: FieldType::Date, | ||
ignore_malformed: true, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use crate::base::{FieldType, SchemaFieldType}; | ||
|
||
use serde_derive::Serialize; | ||
|
||
#[derive(Serialize)] | ||
pub struct EmbeddingsSchema { | ||
#[serde(rename(serialize = "type"))] | ||
field_type: FieldType, | ||
properties: EmbeddingProperties, | ||
} | ||
|
||
impl Default for EmbeddingsSchema { | ||
fn default() -> Self { | ||
EmbeddingsSchema { | ||
field_type: FieldType::Nested, | ||
properties: EmbeddingProperties { | ||
text_chunk: SchemaFieldType::new(FieldType::Text), | ||
vector: VectorSchema::default(), | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Serialize)] | ||
struct EmbeddingProperties { | ||
text_chunk: SchemaFieldType, | ||
vector: VectorSchema, | ||
} | ||
|
||
#[derive(Serialize)] | ||
struct VectorSchema { | ||
#[serde(rename(serialize = "type"))] | ||
field_type: FieldType, | ||
similarity: String, | ||
index: bool, | ||
dims: u32, | ||
} | ||
|
||
impl Default for VectorSchema { | ||
fn default() -> Self { | ||
VectorSchema { | ||
field_type: FieldType::DenseVector, | ||
similarity: "cosine".to_string(), | ||
index: true, | ||
dims: 1024, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod base; | ||
pub mod embeddings; | ||
|
||
pub trait ElasticSchema { | ||
fn build() -> Self; | ||
} |
Oops, something went wrong.