Spaces:
Build error
Build error
Likhith Sai Seemala commited on
Commit ·
584a26b
1
Parent(s): d6e4837
Make Meilisearch optional - use SearXNG-only discovery
Browse files- config.yaml +10 -13
- src/config/mod.rs +13 -4
- src/discovery/mod.rs +24 -7
config.yaml
CHANGED
|
@@ -1,25 +1,23 @@
|
|
| 1 |
# IntentForge v2 Configuration
|
| 2 |
|
| 3 |
[meilisearch]
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
index_name = "intentforge"
|
| 7 |
-
# Binary quantization reduces vector size by 8x with minimal accuracy loss
|
| 8 |
binary_quantization = true
|
| 9 |
-
# Task timeout for Meilisearch operations (secs)
|
| 10 |
task_timeout_secs = 120
|
| 11 |
-
# Hybrid search: 0.7 semantic, 0.3 keyword
|
| 12 |
semantic_ratio = 0.7
|
| 13 |
-
# Cache enabled for production
|
| 14 |
redis_cache_enabled = true
|
| 15 |
|
| 16 |
[qdrant]
|
| 17 |
-
url = "
|
| 18 |
-
|
| 19 |
collection_name = "intentforge"
|
| 20 |
|
| 21 |
[redis]
|
| 22 |
-
url = "
|
| 23 |
# Bloom filter false positive rate
|
| 24 |
bloom_fp_rate = 0.01
|
| 25 |
# SimHash threshold for deduplication
|
|
@@ -101,11 +99,10 @@ level = "info"
|
|
| 101 |
format = "json"
|
| 102 |
|
| 103 |
[extraction]
|
| 104 |
-
# Trafilatura microservice
|
| 105 |
-
|
| 106 |
-
|
| 107 |
batch_size = 16
|
| 108 |
-
# Extraction timeout in seconds
|
| 109 |
timeout_secs = 60
|
| 110 |
|
| 111 |
[inference]
|
|
|
|
| 1 |
# IntentForge v2 Configuration
|
| 2 |
|
| 3 |
[meilisearch]
|
| 4 |
+
# Disabled: Using Qdrant hybrid search (BM25 sparse + dense vectors) instead
|
| 5 |
+
enabled = false
|
| 6 |
+
url = ""
|
| 7 |
+
master_key = ""
|
| 8 |
index_name = "intentforge"
|
|
|
|
| 9 |
binary_quantization = true
|
|
|
|
| 10 |
task_timeout_secs = 120
|
|
|
|
| 11 |
semantic_ratio = 0.7
|
|
|
|
| 12 |
redis_cache_enabled = true
|
| 13 |
|
| 14 |
[qdrant]
|
| 15 |
+
url = "https://6327104c-a2b9-4057-8080-688812c6dcaf.eu-west-2-0.aws.cloud.qdrant.io:6334"
|
| 16 |
+
api_key = "SET_VIA_ENV"
|
| 17 |
collection_name = "intentforge"
|
| 18 |
|
| 19 |
[redis]
|
| 20 |
+
url = "SET_VIA_ENV"
|
| 21 |
# Bloom filter false positive rate
|
| 22 |
bloom_fp_rate = 0.01
|
| 23 |
# SimHash threshold for deduplication
|
|
|
|
| 99 |
format = "json"
|
| 100 |
|
| 101 |
[extraction]
|
| 102 |
+
# Disabled: Using built-in Rust HTML extraction instead of Trafilatura microservice
|
| 103 |
+
enabled = false
|
| 104 |
+
trafilatura_url = ""
|
| 105 |
batch_size = 16
|
|
|
|
| 106 |
timeout_secs = 60
|
| 107 |
|
| 108 |
[inference]
|
src/config/mod.rs
CHANGED
|
@@ -42,6 +42,8 @@ pub struct Config {
|
|
| 42 |
/// Meilisearch configuration
|
| 43 |
#[derive(Debug, Clone, Serialize, Deserialize)]
|
| 44 |
pub struct MeilisearchConfig {
|
|
|
|
|
|
|
| 45 |
pub url: String,
|
| 46 |
pub master_key: String,
|
| 47 |
pub index_name: String,
|
|
@@ -650,6 +652,7 @@ impl Config {
|
|
| 650 |
pub fn default_config() -> Result<Self> {
|
| 651 |
let config = Config {
|
| 652 |
meilisearch: MeilisearchConfig {
|
|
|
|
| 653 |
url: "http://localhost:7700".to_string(),
|
| 654 |
master_key: "masterKey".to_string(),
|
| 655 |
index_name: "intentforge".to_string(),
|
|
@@ -732,10 +735,16 @@ impl Config {
|
|
| 732 |
|
| 733 |
/// Validate configuration
|
| 734 |
pub fn validate(&self) -> Result<()> {
|
| 735 |
-
|
| 736 |
-
!
|
| 737 |
-
|
| 738 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 739 |
anyhow::ensure!(!self.qdrant.url.is_empty(), "Qdrant URL cannot be empty");
|
| 740 |
anyhow::ensure!(!self.redis.url.is_empty(), "Redis URL cannot be empty");
|
| 741 |
anyhow::ensure!(
|
|
|
|
| 42 |
/// Meilisearch configuration
|
| 43 |
#[derive(Debug, Clone, Serialize, Deserialize)]
|
| 44 |
pub struct MeilisearchConfig {
|
| 45 |
+
#[serde(default = "default_true")]
|
| 46 |
+
pub enabled: bool,
|
| 47 |
pub url: String,
|
| 48 |
pub master_key: String,
|
| 49 |
pub index_name: String,
|
|
|
|
| 652 |
pub fn default_config() -> Result<Self> {
|
| 653 |
let config = Config {
|
| 654 |
meilisearch: MeilisearchConfig {
|
| 655 |
+
enabled: true,
|
| 656 |
url: "http://localhost:7700".to_string(),
|
| 657 |
master_key: "masterKey".to_string(),
|
| 658 |
index_name: "intentforge".to_string(),
|
|
|
|
| 735 |
|
| 736 |
/// Validate configuration
|
| 737 |
pub fn validate(&self) -> Result<()> {
|
| 738 |
+
if self.meilisearch.enabled {
|
| 739 |
+
anyhow::ensure!(
|
| 740 |
+
!self.meilisearch.url.is_empty(),
|
| 741 |
+
"Meilisearch URL cannot be empty when enabled"
|
| 742 |
+
);
|
| 743 |
+
anyhow::ensure!(
|
| 744 |
+
!self.meilisearch.master_key.is_empty(),
|
| 745 |
+
"Meilisearch master key cannot be empty when enabled"
|
| 746 |
+
);
|
| 747 |
+
}
|
| 748 |
anyhow::ensure!(!self.qdrant.url.is_empty(), "Qdrant URL cannot be empty");
|
| 749 |
anyhow::ensure!(!self.redis.url.is_empty(), "Redis URL cannot be empty");
|
| 750 |
anyhow::ensure!(
|
src/discovery/mod.rs
CHANGED
|
@@ -35,7 +35,7 @@ pub struct DiscoveryService {
|
|
| 35 |
sources: Arc<SourcesConfig>,
|
| 36 |
redis: ConnectionManager,
|
| 37 |
client: reqwest::Client,
|
| 38 |
-
meili: meilisearch_sdk::client::Client,
|
| 39 |
last_cycle: std::sync::Mutex<Option<std::time::Instant>>,
|
| 40 |
fast_scorer: FastIntentScorer,
|
| 41 |
}
|
|
@@ -79,11 +79,20 @@ impl DiscoveryService {
|
|
| 79 |
.build()
|
| 80 |
.with_context(|| "Failed to create HTTP client for DiscoveryService")?;
|
| 81 |
|
| 82 |
-
let meili =
|
| 83 |
-
&config.meilisearch.url
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
Ok(Self {
|
| 89 |
config,
|
|
@@ -400,12 +409,20 @@ impl DiscoveryService {
|
|
| 400 |
|
| 401 |
/// Extract outbound links from high-signal indexed pages
|
| 402 |
async fn discover_outbound_links(&self) -> Result<()> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
info!("Starting outbound link discovery...");
|
| 404 |
use crate::crawler::find_links;
|
| 405 |
use crate::indexer::IntentDocument;
|
| 406 |
|
| 407 |
// Query Meilisearch for high-quality pages
|
| 408 |
-
let index =
|
| 409 |
|
| 410 |
// Search for documents with relevance_score > threshold
|
| 411 |
let threshold = self.config.discovery.link_threshold;
|
|
|
|
| 35 |
sources: Arc<SourcesConfig>,
|
| 36 |
redis: ConnectionManager,
|
| 37 |
client: reqwest::Client,
|
| 38 |
+
meili: Option<meilisearch_sdk::client::Client>,
|
| 39 |
last_cycle: std::sync::Mutex<Option<std::time::Instant>>,
|
| 40 |
fast_scorer: FastIntentScorer,
|
| 41 |
}
|
|
|
|
| 79 |
.build()
|
| 80 |
.with_context(|| "Failed to create HTTP client for DiscoveryService")?;
|
| 81 |
|
| 82 |
+
let meili = if config.meilisearch.enabled
|
| 83 |
+
&& !config.meilisearch.url.is_empty()
|
| 84 |
+
&& !config.meilisearch.master_key.is_empty()
|
| 85 |
+
{
|
| 86 |
+
let client = meilisearch_sdk::client::Client::new(
|
| 87 |
+
&config.meilisearch.url,
|
| 88 |
+
Some(&config.meilisearch.master_key),
|
| 89 |
+
)
|
| 90 |
+
.with_context(|| "Failed to create Meilisearch client for DiscoveryService")?;
|
| 91 |
+
Some(client)
|
| 92 |
+
} else {
|
| 93 |
+
tracing::info!("Meilisearch disabled in config - outbound link discovery will be disabled");
|
| 94 |
+
None
|
| 95 |
+
};
|
| 96 |
|
| 97 |
Ok(Self {
|
| 98 |
config,
|
|
|
|
| 409 |
|
| 410 |
/// Extract outbound links from high-signal indexed pages
|
| 411 |
async fn discover_outbound_links(&self) -> Result<()> {
|
| 412 |
+
let meili = match &self.meili {
|
| 413 |
+
Some(client) => client,
|
| 414 |
+
None => {
|
| 415 |
+
tracing::debug!("Outbound link discovery skipped: Meilisearch is disabled");
|
| 416 |
+
return Ok(());
|
| 417 |
+
}
|
| 418 |
+
};
|
| 419 |
+
|
| 420 |
info!("Starting outbound link discovery...");
|
| 421 |
use crate::crawler::find_links;
|
| 422 |
use crate::indexer::IntentDocument;
|
| 423 |
|
| 424 |
// Query Meilisearch for high-quality pages
|
| 425 |
+
let index = meili.index(&self.config.meilisearch.index_name);
|
| 426 |
|
| 427 |
// Search for documents with relevance_score > threshold
|
| 428 |
let threshold = self.config.discovery.link_threshold;
|