fix
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-01-02 22:56:51 +01:00
parent 586d3f4c0c
commit 6700d4d817
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 10 additions and 9 deletions

View file

@ -11,7 +11,7 @@ services:
- "RUST_LOG=info"
- "ROCKET_ADDRESS=0.0.0.0"
- "DATABASE_URL=postgres://user:pass@postgres/webarc"
command: "webarc serve"
command: "/webarc serve"
postgres:
# Any Postgres with support for pgvector

View file

@ -29,13 +29,12 @@ pub struct DocEmbedding {
}
impl DocEmbedding {
pub async fn total_chunks(&self) -> i32 {
let res: (i32,) = sqlx::query_as(
"SELECT MAX(chunk) FROM doc_embedding WHERE domain = $1 AND path = $2 AND ver = $3",
pub async fn total_chunks(&self) -> i64 {
let res: (i64,) = sqlx::query_as(
"SELECT COUNT(chunk) FROM doc_embedding WHERE domain = $1 AND path = $2",
)
.bind(&self.domain)
.bind(&self.path)
.bind(&self.ver)
.fetch_one(get_pg!())
.await
.unwrap();
@ -48,12 +47,12 @@ impl DocEmbedding {
pub struct SearchResult {
pub domain: String,
pub path: String,
pub total_chunks: i32,
pub total_chunks: i64,
pub chunks: Vec<DocEmbedding>,
}
impl SearchResult {
pub fn new(domain: String, path: String, total_chunks: i32) -> Self {
pub fn new(domain: String, path: String, total_chunks: i64) -> Self {
Self {
domain,
path,
@ -63,8 +62,10 @@ impl SearchResult {
}
pub fn similarity(&self) -> f64 {
total_score(&self.chunks)
* (f64::from(self.chunks.len() as u32) / f64::from(self.total_chunks))
let chunks = f64::from(self.chunks.len() as u32);
let total = f64::from(self.total_chunks as i32);
let match_percent = chunks / total;
total_score(&self.chunks) * match_percent
}
}