108 lines
2.8 KiB
Rust
108 lines
2.8 KiB
Rust
use qdrant_client::qdrant::Filter;
|
|
|
|
use super::client::SearchResult;
|
|
|
|
/// Vector search operations for Qdrant-backed entity retrieval.
|
|
impl super::EmbedService {
|
|
pub async fn search_issues(
|
|
&self,
|
|
query: &str,
|
|
limit: usize,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search(query, "issue", &self.model_name, limit)
|
|
.await
|
|
}
|
|
|
|
pub async fn search_repos(
|
|
&self,
|
|
query: &str,
|
|
limit: usize,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search(query, "repo", &self.model_name, limit)
|
|
.await
|
|
}
|
|
|
|
pub async fn search_issues_filtered(
|
|
&self,
|
|
query: &str,
|
|
limit: usize,
|
|
filter: Filter,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search_with_filter(query, "issue", &self.model_name, limit, filter)
|
|
.await
|
|
}
|
|
|
|
/// Search repo tags by semantic similarity within a project.
|
|
/// Filters by project_id (stored in entity_id) for project isolation.
|
|
pub async fn search_tags(
|
|
&self,
|
|
query: &str,
|
|
project_id: &str,
|
|
limit: usize,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
let mut results = self
|
|
.client
|
|
.search(query, "repo_tag", &self.model_name, limit + 1)
|
|
.await?;
|
|
results.retain(|r| r.payload.entity_id == project_id);
|
|
results.truncate(limit);
|
|
Ok(results)
|
|
}
|
|
|
|
/// Search skills by semantic similarity within a project.
|
|
pub async fn search_skills(
|
|
&self,
|
|
query: &str,
|
|
project_uuid: &str,
|
|
limit: usize,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search_skills(query, &self.model_name, project_uuid, limit)
|
|
.await
|
|
}
|
|
|
|
/// Search past conversation messages by semantic similarity within a room.
|
|
pub async fn search_memories(
|
|
&self,
|
|
query: &str,
|
|
project_name: &str,
|
|
room_id: &str,
|
|
limit: usize,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search_memories(
|
|
query,
|
|
&self.model_name,
|
|
project_name,
|
|
room_id,
|
|
limit,
|
|
self.dimensions,
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub async fn search_memories_after_seq(
|
|
&self,
|
|
query: &str,
|
|
project_name: &str,
|
|
room_id: &str,
|
|
limit: usize,
|
|
after_seq: Option<i64>,
|
|
) -> crate::Result<Vec<SearchResult>> {
|
|
self.client
|
|
.search_memories_after_seq(
|
|
query,
|
|
&self.model_name,
|
|
project_name,
|
|
room_id,
|
|
limit,
|
|
self.dimensions,
|
|
after_seq,
|
|
)
|
|
.await
|
|
}
|
|
}
|