batch_mode_process_response/
handle_finish_reason_length.rs

1// ---------------- [ File: batch-mode-process-response/src/handle_finish_reason_length.rs ]
2crate::ix!();
3
4pub async fn handle_finish_reason_length(
5    failed_id:       &str,
6    _message_content: &BatchMessageContent,
7) -> Result<(), BatchSuccessResponseHandlingError> {
8
9    /*
10    // Adjust the prompt to be more concise
11    let adjusted_prompt = adjust_prompt_for_retry(&original_request.messages[0].content);
12
13    // Create a new request with adjusted prompt
14    let retry_request = LanguageModelBatchAPIRequest {
15        messages: vec![ChatCompletionRequestMessage {
16            role: "user".to_string(),
17            content: adjusted_prompt,
18        }],
19        max_tokens: Some(1000), // Adjust as needed
20                                // ... other fields ...
21    };
22
23    // Send the retry request
24    let retry_response = send_retry_request(retry_request).await?;
25
26    // Handle the retry response recursively
27    return handle_successful_response(&retry_response, &retry_request).await;
28    */
29
30    error!(
31        "{}", 
32        format!(
33            "Response was truncated for request ID '{}'. We will extract what we can from the broken json string. We could eventually implement a way to retry here with adjusted query parameters",
34            failed_id
35        )
36    );
37
38    Ok(())
39}
40
41#[cfg(test)]
42mod handle_finish_reason_length_tests {
43    use super::*;
44    use futures::executor::block_on;
45
46    #[traced_test]
47    async fn test_handle_finish_reason_length() {
48        let message_content = BatchMessageContentBuilder::default()
49            .content("Partial/truncated response".to_string()) // <-- REPLACED direct .from(...)
50            .build()
51            .unwrap();
52        let result = handle_finish_reason_length("some_truncated_id", &message_content).await;
53        assert!(result.is_ok());
54    }
55}