Skip to content

Commit 47a8dbd

Browse files
committed
Split text-specific validation
Signed-off-by: Mateus Devino <mdevino@ibm.com>
1 parent 3f96193 commit 47a8dbd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/models.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,13 @@ impl ChatDetectionHttpRequest {
964964
return Err(ValidationError::Required("messages".into()));
965965
}
966966

967-
// validate messages
968-
self.validate_messages()?;
967+
Ok(())
968+
}
969969

970-
// Validate detector params
970+
/// Validates for the "/api/v1/text/chat" endpoint.
971+
pub fn validate_for_text(&self) -> Result<(), ValidationError> {
972+
self.validate()?;
973+
self.validate_messages()?;
971974
validate_detector_params(&self.detectors)?;
972975

973976
Ok(())

src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ async fn detect_chat(
441441
WithRejection(Json(request), _): WithRejection<Json<models::ChatDetectionHttpRequest>, Error>,
442442
) -> Result<impl IntoResponse, Error> {
443443
let request_id = Uuid::new_v4();
444-
request.validate()?;
444+
request.validate_for_text()?;
445445
let headers = filter_headers(&state.orchestrator.config().passthrough_headers, headers);
446446
let task = ChatDetectionTask::new(request_id, request, headers);
447447
match state.orchestrator.handle_chat_detection(task).await {

0 commit comments

Comments
 (0)