Skip to content

Commit 4afa5b7

Browse files
committed
feat(server): allow users to pass in custom model for rag on specified chunks
1 parent 1374389 commit 4afa5b7

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

clients/ts-sdk/openapi.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14589,6 +14589,11 @@
1458914589
"description": "Metadata is any metadata you want to associate w/ the event that is created from this request",
1459014590
"nullable": true
1459114591
},
14592+
"model": {
14593+
"type": "string",
14594+
"description": "Model to use for the completion. If not specified, the default model configured for the dataset will be used.",
14595+
"nullable": true
14596+
},
1459214597
"presence_penalty": {
1459314598
"type": "number",
1459414599
"format": "float",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,10 @@ export type GenerateOffChunksReqPayload = {
22642264
* Metadata is any metadata you want to associate w/ the event that is created from this request
22652265
*/
22662266
metadata?: unknown;
2267+
/**
2268+
* Model to use for the completion. If not specified, the default model configured for the dataset will be used.
2269+
*/
2270+
model?: (string) | null;
22672271
/**
22682272
* Presence penalty is a number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Default is 0.7.
22692273
*/

server/src/handlers/chunk_handler.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,6 +2523,8 @@ pub struct GenerateOffChunksReqPayload {
25232523
pub image_config: Option<ImageConfig>,
25242524
/// Context options to use for the completion. If not specified, all options will default to false.
25252525
pub context_options: Option<ContextOptions>,
2526+
/// Model to use for the completion. If not specified, the default model configured for the dataset will be used.
2527+
pub model: Option<String>,
25262528
}
25272529

25282530
/// RAG on Specified Chunks
@@ -2584,7 +2586,10 @@ pub async fn generate_off_chunks(
25842586

25852587
let base_url = dataset_config.LLM_BASE_URL;
25862588
let rag_prompt = dataset_config.RAG_PROMPT.clone();
2587-
let chosen_model = dataset_config.LLM_DEFAULT_MODEL;
2589+
let chosen_model = data
2590+
.model
2591+
.clone()
2592+
.unwrap_or(dataset_config.LLM_DEFAULT_MODEL);
25882593

25892594
let base_url = if base_url.is_empty() {
25902595
"https://openrouter.ai/api/v1".into()

server/src/handlers/message_handler.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ pub async fn create_message(
289289
redis_pool,
290290
dataset_config,
291291
create_message_data,
292+
#[cfg(feature = "hallucination-detection")]
293+
hallucination_detector,
292294
)
293295
.await
294296
} else {
@@ -704,6 +706,8 @@ pub async fn regenerate_message_patch(
704706
redis_pool,
705707
dataset_config,
706708
create_message_data,
709+
#[cfg(feature = "hallucination-detection")]
710+
hallucination_detector,
707711
)
708712
.await;
709713
} else {
@@ -792,6 +796,8 @@ pub async fn regenerate_message_patch(
792796
redis_pool,
793797
dataset_config,
794798
create_message_data,
799+
#[cfg(feature = "hallucination-detection")]
800+
hallucination_detector,
795801
)
796802
.await
797803
} else {

server/src/operators/message_operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ pub async fn stream_response_with_agentic_search(
16981698
redis_pool: web::Data<RedisPool>,
16991699
dataset_config: DatasetConfiguration,
17001700
create_message_req_payload: CreateMessageReqPayload,
1701-
#[cfg(feature = "hallucination-detection")] hallucination_detector: web::Data<
1701+
#[cfg(feature = "hallucination-detection")] _hallucination_detector: web::Data<
17021702
HallucinationDetector,
17031703
>,
17041704
) -> Result<HttpResponse, actix_web::Error> {

yarn.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7047,6 +7047,10 @@ postcss@^8.3.11, postcss@^8.4.32, postcss@^8.4.43, postcss@^8.4.45, postcss@^8.4
70477047
version "8.5.3"
70487048
resolved "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz"
70497049
integrity sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==
7050+
dependencies:
7051+
nanoid "^3.3.8"
7052+
picocolors "^1.1.1"
7053+
source-map-js "^1.2.1"
70507054

70517055
preact@^10.25.1:
70527056
version "10.26.6"
@@ -7826,7 +7830,7 @@ solid-use@^0.9.0:
78267830
resolved "https://registry.npmjs.org/solid-use/-/solid-use-0.9.1.tgz"
78277831
integrity sha512-UwvXDVPlrrbj/9ewG9ys5uL2IO4jSiwys2KPzK4zsnAcmEl7iDafZWW1Mo4BSEWOmQCGK6IvpmGHo1aou8iOFw==
78287832

7829-
source-map-js@^1.0.1, source-map-js@^1.2.1:
7833+
source-map-js@^1.0.1:
78307834
version "1.2.1"
78317835
resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz"
78327836
integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==

0 commit comments

Comments
 (0)