Skip to content

Commit

Permalink
1. ignore some languages; 2. improve log for debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Aug 21, 2023
1 parent 3d19b22 commit d23d55a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jarvis"
version = "0.7.10"
version = "0.7.11"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
4 changes: 2 additions & 2 deletions src/api/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ pub async fn public(
rid = rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
elapsed = start.elapsed().as_millis() as u64;
"success",
)
Expand All @@ -466,7 +466,7 @@ pub async fn public(
rid = rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
elapsed = start.elapsed().as_millis() as u64;
"{}", err,
)
Expand Down
8 changes: 4 additions & 4 deletions src/api/summarizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async fn summarize(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
version = version,
elapsed = ai_elapsed;
"{}", err.to_string(),
Expand All @@ -185,7 +185,7 @@ async fn summarize(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
version = version,
elapsed = ai_elapsed;
"success",
Expand All @@ -212,7 +212,7 @@ async fn summarize(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
version = version,
elapsed = start.elapsed().as_millis() as u64,
summary = doc.summary.len(),
Expand All @@ -226,7 +226,7 @@ async fn summarize(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = language.to_639_3().to_string(),
version = version,
elapsed = start.elapsed().as_millis() as u64,
summary = doc.summary.len(),
Expand Down
24 changes: 14 additions & 10 deletions src/api/translating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub async fn get(
})))
}

const IGNORE_LANGGUAGES: [&'static str; 5] = ["abk", "ava", "bak", "lim", "nya"];

pub async fn list_languages(
to: PackObject<()>,
State(_): State<Arc<AppState>>,
Expand All @@ -85,11 +87,13 @@ pub async fn list_languages(
continue;
}

list.push((
lg.to_639_3().to_string(),
lg.to_name().to_string(),
lg.to_autonym().unwrap().to_string(),
));
if !IGNORE_LANGGUAGES.contains(&lg.to_639_3()) {
list.push((
lg.to_639_3().to_string(),
lg.to_name().to_string(),
lg.to_autonym().unwrap().to_string(),
));
}
}
Ok(to.with(SuccessResponse {
total_size: Some(list.len() as u64),
Expand Down Expand Up @@ -263,7 +267,7 @@ async fn translate(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = target_lang.to_639_3().to_string(),
version = version,
elapsed = ai_elapsed;
"{}", err.to_string(),
Expand All @@ -276,7 +280,7 @@ async fn translate(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = target_lang.to_639_3().to_string(),
version = version,
elapsed = ai_elapsed;
"success",
Expand All @@ -298,7 +302,7 @@ async fn translate(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = target_lang.to_639_3().to_string(),
version = version,
elapsed = start.elapsed().as_millis() as u64,
pieces = pieces;
Expand All @@ -319,7 +323,7 @@ async fn translate(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = target_lang.to_639_3().to_string(),
version = version,
elapsed = start.elapsed().as_millis() as u64,
pieces = pieces;
Expand All @@ -332,7 +336,7 @@ async fn translate(
rid = &rid,
gid = gid.to_string(),
cid = cid.to_string(),
language = language.to_string(),
language = target_lang.to_639_3().to_string(),
version = version,
elapsed = start.elapsed().as_millis() as u64,
pieces = pieces;
Expand Down
10 changes: 6 additions & 4 deletions src/db/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use qdrant_client::client::{QdrantClient, QdrantClientConfig};
use tokio::time::Duration;

pub use qdrant_client::qdrant::{
r#match::MatchValue, Condition, FieldCondition, Filter, Match, PointId, PointStruct,
ReadConsistency, SearchPoints, SearchResponse, Value, Vectors, WithPayloadSelector,
WithVectorsSelector,
r#match::MatchValue, read_consistency, Condition, FieldCondition, Filter, Match, PointId,
PointStruct, ReadConsistency, SearchPoints, SearchResponse, Value, Vectors,
WithPayloadSelector, WithVectorsSelector,
};

use crate::conf;
Expand Down Expand Up @@ -64,7 +64,9 @@ impl Qdrant {
&ids,
Some(WithVectorsSelector::from(true)),
Some(WithPayloadSelector::from(true)),
Some(ReadConsistency::default()),
Some(ReadConsistency {
value: Some(read_consistency::Value::Type(1)),
}),
)
.await?;

Expand Down
3 changes: 3 additions & 0 deletions src/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl OpenAI {
rid = rid,
user = user,
fixed = content.is_ok(),
input = text,
output = output;
"",
);
Expand All @@ -177,6 +178,7 @@ impl OpenAI {
rid = rid,
user = user,
fixed = false,
input = text,
output = choice.message.content;
"{}", &er,
);
Expand Down Expand Up @@ -214,6 +216,7 @@ impl OpenAI {
elapsed = start.elapsed().as_millis() as u64,
rid = rid,
user = user,
input = text,
output = choice.message.content;
"{}", err,
);
Expand Down

0 comments on commit d23d55a

Please sign in to comment.