Skip to content

Commit 35218e5

Browse files
densumeshskeptrunedev
authored andcommitted
feature: add agentic search
1 parent d355de3 commit 35218e5

20 files changed

Lines changed: 959 additions & 309 deletions

clients/ts-sdk/openapi.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11670,11 +11670,6 @@
1167011670
"description": "No result message for when there are no chunks found above the score threshold.",
1167111671
"nullable": true
1167211672
},
11673-
"only_include_docs_used": {
11674-
"type": "boolean",
11675-
"description": "Only include docs used in the completion. If not specified, this defaults to false.",
11676-
"nullable": true
11677-
},
1167811673
"page_size": {
1167911674
"type": "integer",
1168011675
"format": "int64",
@@ -11732,6 +11727,11 @@
1173211727
],
1173311728
"nullable": true
1173411729
},
11730+
"use_agentic_search": {
11731+
"type": "boolean",
11732+
"description": "If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.",
11733+
"nullable": true
11734+
},
1173511735
"use_group_search": {
1173611736
"type": "boolean",
1173711737
"description": "If use_group_search is set to true, the search will be conducted using the `search_over_groups` api. If not specified, this defaults to false.",
@@ -12766,11 +12766,6 @@
1276612766
"description": "No result message for when there are no chunks found above the score threshold.",
1276712767
"nullable": true
1276812768
},
12769-
"only_include_docs_used": {
12770-
"type": "boolean",
12771-
"description": "Only include docs used in the completion. If not specified, this defaults to false.",
12772-
"nullable": true
12773-
},
1277412769
"page_size": {
1277512770
"type": "integer",
1277612771
"format": "int64",
@@ -12828,6 +12823,11 @@
1282812823
],
1282912824
"nullable": true
1283012825
},
12826+
"use_agentic_search": {
12827+
"type": "boolean",
12828+
"description": "If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.",
12829+
"nullable": true
12830+
},
1283112831
"use_group_search": {
1283212832
"type": "boolean",
1283312833
"nullable": true
@@ -19323,11 +19323,6 @@
1932319323
"description": "No result message for when there are no chunks found above the score threshold.",
1932419324
"nullable": true
1932519325
},
19326-
"only_include_docs_used": {
19327-
"type": "boolean",
19328-
"description": "Only include docs used in the completion. If not specified, this defaults to false.",
19329-
"nullable": true
19330-
},
1933119326
"page_size": {
1933219327
"type": "integer",
1933319328
"format": "int64",
@@ -19385,6 +19380,11 @@
1938519380
],
1938619381
"nullable": true
1938719382
},
19383+
"use_agentic_search": {
19384+
"type": "boolean",
19385+
"description": "If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.",
19386+
"nullable": true
19387+
},
1938819388
"use_group_search": {
1938919389
"type": "boolean",
1939019390
"description": "If use_group_search is set to true, the search will be conducted using the `search_over_groups` api. If not specified, this defaults to false.",

clients/ts-sdk/src/types.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,6 @@ export type CreateMessageReqPayload = {
10861086
* No result message for when there are no chunks found above the score threshold.
10871087
*/
10881088
no_result_message?: (string) | null;
1089-
/**
1090-
* Only include docs used in the completion. If not specified, this defaults to false.
1091-
*/
1092-
only_include_docs_used?: (boolean) | null;
10931089
/**
10941090
* Page size is the number of chunks to fetch during RAG. If 0, then no search will be performed. If specified, this will override the N retrievals to include in the dataset configuration. Default is None.
10951091
*/
@@ -1117,6 +1113,10 @@ export type CreateMessageReqPayload = {
11171113
*/
11181114
topic_id: string;
11191115
typo_options?: ((TypoOptions) | null);
1116+
/**
1117+
* If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.
1118+
*/
1119+
use_agentic_search?: (boolean) | null;
11201120
/**
11211121
* If use_group_search is set to true, the search will be conducted using the `search_over_groups` api. If not specified, this defaults to false.
11221122
*/
@@ -1594,10 +1594,6 @@ export type EditMessageReqPayload = {
15941594
* No result message for when there are no chunks found above the score threshold.
15951595
*/
15961596
no_result_message?: (string) | null;
1597-
/**
1598-
* Only include docs used in the completion. If not specified, this defaults to false.
1599-
*/
1600-
only_include_docs_used?: (boolean) | null;
16011597
/**
16021598
* Page size is the number of chunks to fetch during RAG. If 0, then no search will be performed. If specified, this will override the N retrievals to include in the dataset configuration. Default is None.
16031599
*/
@@ -1625,6 +1621,10 @@ export type EditMessageReqPayload = {
16251621
*/
16261622
topic_id: string;
16271623
typo_options?: ((TypoOptions) | null);
1624+
/**
1625+
* If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.
1626+
*/
1627+
use_agentic_search?: (boolean) | null;
16281628
use_group_search?: (boolean) | null;
16291629
/**
16301630
* If true, quoted and - prefixed words will be parsed from the queries and used as required and negated words respectively. Default is false.
@@ -3695,10 +3695,6 @@ export type RegenerateMessageReqPayload = {
36953695
* No result message for when there are no chunks found above the score threshold.
36963696
*/
36973697
no_result_message?: (string) | null;
3698-
/**
3699-
* Only include docs used in the completion. If not specified, this defaults to false.
3700-
*/
3701-
only_include_docs_used?: (boolean) | null;
37023698
/**
37033699
* Page size is the number of chunks to fetch during RAG. If 0, then no search will be performed. If specified, this will override the N retrievals to include in the dataset configuration. Default is None.
37043700
*/
@@ -3726,6 +3722,10 @@ export type RegenerateMessageReqPayload = {
37263722
*/
37273723
topic_id: string;
37283724
typo_options?: ((TypoOptions) | null);
3725+
/**
3726+
* If true, the search will be conducted using llm tool calling. If not specified, this defaults to false.
3727+
*/
3728+
use_agentic_search?: (boolean) | null;
37293729
/**
37303730
* If use_group_search is set to true, the search will be conducted using the `search_over_groups` api. If not specified, this defaults to false.
37313731
*/

server/src/bin/csv-jsonl-worker.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ async fn file_worker(
228228
Err(err) => {
229229
log::error!(
230230
"File {} has not yet been uploaded to the signed put url: {:?}",
231-
csv_jsonl_worker_message.file_id.to_string(),
231+
csv_jsonl_worker_message.file_id,
232232
err.to_string(),
233233
);
234234

@@ -619,10 +619,7 @@ fn convert_value_to_chunkreqpayload(
619619
}
620620
_ => value.clone(),
621621
};
622-
let chunk_html = match serde_json::to_string(&cleaned_value) {
623-
Ok(chunk_html) => Some(chunk_html),
624-
Err(_) => None,
625-
};
622+
let chunk_html = serde_json::to_string(&cleaned_value).ok();
626623
let mut chunk_req_payload = ChunkReqPayload {
627624
chunk_html,
628625
semantic_content: None,

server/src/bin/ingestion-worker.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,7 @@ pub async fn bulk_upload_chunks(
648648
} else {
649649
let content_size = fulltext_content_and_boosts.len();
650650

651-
Ok(std::iter::repeat(vec![(0, 0.0)])
652-
.take(content_size)
653-
.collect())
651+
Ok(std::iter::repeat_n(vec![(0, 0.0)], content_size).collect())
654652
}?;
655653

656654
let bm25_vectors = if dataset_config.BM25_ENABLED

server/src/data/models.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,7 +3667,6 @@ impl DatasetConfigurationDTO {
36673667
"DOCUMENT_UPLOAD_FEATURE": true,
36683668
"FILE_NAME_KEY": "file_name_key",
36693669
}))]
3670-
36713670
pub struct DatasetAndOrgWithSubAndPlan {
36723671
pub dataset: Dataset,
36733672
pub organization: OrganizationWithSubAndPlan,
@@ -4541,13 +4540,13 @@ impl ApiKeyRequestParams {
45414540
currency: payload.currency,
45424541
context_options: payload.context_options,
45434542
no_result_message: self.no_result_message.or(payload.no_result_message),
4544-
only_include_docs_used: payload.only_include_docs_used,
45454543
use_quote_negated_terms: self
45464544
.use_quote_negated_terms
45474545
.or(payload.use_quote_negated_terms),
45484546
remove_stop_words: self.remove_stop_words.or(payload.remove_stop_words),
45494547
typo_options: self.typo_options.or(payload.typo_options),
45504548
metadata: payload.metadata,
4549+
use_agentic_search: payload.use_agentic_search,
45514550
}
45524551
}
45534552

@@ -5149,7 +5148,7 @@ pub enum RangeCondition {
51495148
Int(i64),
51505149
}
51515150

5152-
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
5151+
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
51535152
#[schema(example = json!({
51545153
"gte": 0.0,
51555154
"lte": 1.0,
@@ -5259,7 +5258,7 @@ pub struct HasChunkIDCondition {
52595258
pub tracking_ids: Option<Vec<String>>,
52605259
}
52615260

5262-
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
5261+
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
52635262
#[schema(example = json!({
52645263
"field": "metadata.key1",
52655264
"match": ["value1", "value2"],
@@ -8263,7 +8262,7 @@ pub enum SearchAnalyticsResponse {
82638262
#[schema(title = "CountQueries")]
82648263
CountQueries(QueryCountResponse),
82658264
#[schema(title = "QueryDetails")]
8266-
QueryDetails(SearchQueryEvent),
8265+
QueryDetails(Box<SearchQueryEvent>),
82678266
#[schema(title = "PopularFilters")]
82688267
PopularFilters(PopularFiltersResponse),
82698268
#[schema(title = "CTRMetricsOverTime")]
@@ -8297,7 +8296,7 @@ pub enum RecommendationAnalyticsResponse {
82978296
#[schema(title = "RecommendationQueries")]
82988297
RecommendationQueries(RecommendationsEventResponse),
82998298
#[schema(title = "QueryDetails")]
8300-
QueryDetails(RecommendationEvent),
8299+
QueryDetails(Box<RecommendationEvent>),
83018300
#[schema(title = "RecommendationUsageGraph")]
83028301
RecommendationUsageGraph(RecommendationUsageGraphResponse),
83038302
#[schema(title = "RecommendationsPerUser")]
@@ -9424,10 +9423,10 @@ impl<'de> Deserialize<'de> for CreateMessageReqPayload {
94249423
pub use_group_search: Option<bool>,
94259424
pub context_options: Option<ContextOptions>,
94269425
pub no_result_message: Option<String>,
9427-
pub only_include_docs_used: Option<bool>,
94289426
pub currency: Option<String>,
94299427
metadata: Option<serde_json::Value>,
94309428
pub rag_context: Option<String>,
9429+
pub use_agentic_search: Option<bool>,
94319430
#[serde(flatten)]
94329431
other: std::collections::HashMap<String, serde_json::Value>,
94339432
use_quote_negated_terms: Option<bool>,
@@ -9469,10 +9468,10 @@ impl<'de> Deserialize<'de> for CreateMessageReqPayload {
94699468
no_result_message: helper.no_result_message,
94709469
metadata: helper.metadata,
94719470
rag_context: helper.rag_context,
9472-
only_include_docs_used: helper.only_include_docs_used,
94739471
use_quote_negated_terms: helper.use_quote_negated_terms,
94749472
remove_stop_words: helper.remove_stop_words,
94759473
typo_options: helper.typo_options,
9474+
use_agentic_search: helper.use_agentic_search,
94769475
})
94779476
}
94789477
}
@@ -9498,7 +9497,6 @@ impl<'de> Deserialize<'de> for RegenerateMessageReqPayload {
94989497
pub use_group_search: Option<bool>,
94999498
pub context_options: Option<ContextOptions>,
95009499
pub no_result_message: Option<String>,
9501-
pub only_include_docs_used: Option<bool>,
95029500
pub currency: Option<String>,
95039501
metadata: Option<serde_json::Value>,
95049502
#[serde(flatten)]
@@ -9507,6 +9505,7 @@ impl<'de> Deserialize<'de> for RegenerateMessageReqPayload {
95079505
pub remove_stop_words: Option<bool>,
95089506
pub typo_options: Option<TypoOptions>,
95099507
pub rag_context: Option<String>,
9508+
pub use_agentic_search: Option<bool>,
95109509
}
95119510

95129511
let mut helper = Helper::deserialize(deserializer)?;
@@ -9539,11 +9538,11 @@ impl<'de> Deserialize<'de> for RegenerateMessageReqPayload {
95399538
context_options,
95409539
metadata: helper.metadata,
95419540
no_result_message: helper.no_result_message,
9542-
only_include_docs_used: helper.only_include_docs_used,
95439541
use_quote_negated_terms: helper.use_quote_negated_terms,
95449542
remove_stop_words: helper.remove_stop_words,
95459543
typo_options: helper.typo_options,
95469544
rag_context: helper.rag_context,
9545+
use_agentic_search: helper.use_agentic_search,
95479546
})
95489547
}
95499548
}
@@ -9573,7 +9572,6 @@ impl<'de> Deserialize<'de> for EditMessageReqPayload {
95739572
pub user_id: Option<String>,
95749573
pub context_options: Option<ContextOptions>,
95759574
pub no_result_message: Option<String>,
9576-
pub only_include_docs_used: Option<bool>,
95779575
pub currency: Option<String>,
95789576
metadata: Option<serde_json::Value>,
95799577
#[serde(flatten)]
@@ -9582,6 +9580,7 @@ impl<'de> Deserialize<'de> for EditMessageReqPayload {
95829580
pub remove_stop_words: Option<bool>,
95839581
pub typo_options: Option<TypoOptions>,
95849582
pub rag_context: Option<String>,
9583+
pub use_agentic_search: Option<bool>,
95859584
}
95869585

95879586
let mut helper = Helper::deserialize(deserializer)?;
@@ -9618,11 +9617,11 @@ impl<'de> Deserialize<'de> for EditMessageReqPayload {
96189617
context_options,
96199618
metadata: helper.metadata,
96209619
no_result_message: helper.no_result_message,
9621-
only_include_docs_used: helper.only_include_docs_used,
96229620
use_quote_negated_terms: helper.use_quote_negated_terms,
96239621
remove_stop_words: helper.remove_stop_words,
96249622
typo_options: helper.typo_options,
96259623
rag_context: helper.rag_context,
9624+
use_agentic_search: helper.use_agentic_search,
96269625
})
96279626
}
96289627
}

server/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ impl From<DBError> for ServiceError {
126126
}
127127
}
128128

129+
impl From<actix_web::Error> for ServiceError {
130+
fn from(error: actix_web::Error) -> Self {
131+
ServiceError::InternalServerError(error.to_string())
132+
}
133+
}
134+
129135
pub fn custom_json_error_handler(
130136
err: JsonPayloadError,
131137
_req: &actix_web::HttpRequest,

server/src/handlers/analytics_handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub async fn get_search_analytics(
283283
)
284284
.await?;
285285

286-
SearchAnalyticsResponse::QueryDetails(query)
286+
SearchAnalyticsResponse::QueryDetails(Box::new(query))
287287
}
288288
SearchAnalytics::CountQueries {
289289
filter,
@@ -745,7 +745,7 @@ pub async fn get_recommendation_analytics(
745745
clickhouse_client.get_ref(),
746746
)
747747
.await?;
748-
RecommendationAnalyticsResponse::QueryDetails(recommendation_query)
748+
RecommendationAnalyticsResponse::QueryDetails(Box::new(recommendation_query))
749749
}
750750
RecommendationAnalytics::RecommendationUsageGraph {
751751
filter,

0 commit comments

Comments
 (0)