Skip to content

Commit 8bd6ce3

Browse files
committed
delete (now) useless roundtrip tests
1 parent c5112a8 commit 8bd6ce3

File tree

5 files changed

+0
-1269
lines changed

5 files changed

+0
-1269
lines changed

llm/llm/src/durability.rs

Lines changed: 0 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -460,235 +460,4 @@ mod durable_impl {
460460
write!(f, "UnusedError")
461461
}
462462
}
463-
464-
#[cfg(test)]
465-
mod tests {
466-
use crate::durability::durable_impl::SendInput;
467-
use crate::golem::llm::llm::{
468-
ChatEvent, CompleteResponse, Config, ContentPart, Error, ErrorCode, FinishReason,
469-
ImageDetail, ImageReference, ImageSource, ImageUrl, Message, ResponseMetadata, Role,
470-
ToolCall, Usage,
471-
};
472-
use golem_rust::value_and_type::{FromValueAndType, IntoValueAndType};
473-
use golem_rust::wasm_rpc::WitTypeNode;
474-
use std::fmt::Debug;
475-
476-
fn roundtrip_test<T: Debug + Clone + PartialEq + IntoValueAndType + FromValueAndType>(
477-
value: T,
478-
) {
479-
let vnt = value.clone().into_value_and_type();
480-
let extracted = T::from_value_and_type(vnt).unwrap();
481-
assert_eq!(value, extracted);
482-
}
483-
484-
#[test]
485-
fn image_detail_roundtrip() {
486-
roundtrip_test(ImageDetail::Low);
487-
roundtrip_test(ImageDetail::High);
488-
roundtrip_test(ImageDetail::Auto);
489-
}
490-
491-
#[test]
492-
fn error_roundtrip() {
493-
roundtrip_test(Error {
494-
code: ErrorCode::InvalidRequest,
495-
message: "Invalid request".to_string(),
496-
provider_error_json: Some("Provider error".to_string()),
497-
});
498-
roundtrip_test(Error {
499-
code: ErrorCode::AuthenticationFailed,
500-
message: "Authentication failed".to_string(),
501-
provider_error_json: None,
502-
});
503-
}
504-
505-
#[test]
506-
fn image_url_roundtrip() {
507-
roundtrip_test(ImageUrl {
508-
url: "https://example.com/image.png".to_string(),
509-
detail: Some(ImageDetail::High),
510-
});
511-
roundtrip_test(ImageUrl {
512-
url: "https://example.com/image.png".to_string(),
513-
detail: None,
514-
});
515-
}
516-
517-
#[test]
518-
fn image_source_roundtrip() {
519-
roundtrip_test(ImageSource {
520-
data: vec![0, 1, 2, 3, 4, 5],
521-
mime_type: "image/jpeg".to_string(),
522-
detail: Some(ImageDetail::High),
523-
});
524-
roundtrip_test(ImageSource {
525-
data: vec![255, 254, 253, 252],
526-
mime_type: "image/png".to_string(),
527-
detail: None,
528-
});
529-
}
530-
531-
#[test]
532-
fn content_part_roundtrip() {
533-
roundtrip_test(ContentPart::Text("Hello".to_string()));
534-
roundtrip_test(ContentPart::Image(ImageReference::Url(ImageUrl {
535-
url: "https://example.com/image.png".to_string(),
536-
detail: Some(ImageDetail::Low),
537-
})));
538-
roundtrip_test(ContentPart::Image(ImageReference::Inline(ImageSource {
539-
data: vec![0, 1, 2, 3, 4, 5],
540-
mime_type: "image/jpeg".to_string(),
541-
detail: Some(ImageDetail::Auto),
542-
})));
543-
}
544-
545-
#[test]
546-
fn usage_roundtrip() {
547-
roundtrip_test(Usage {
548-
input_tokens: Some(100),
549-
output_tokens: Some(200),
550-
total_tokens: Some(300),
551-
});
552-
roundtrip_test(Usage {
553-
input_tokens: None,
554-
output_tokens: None,
555-
total_tokens: None,
556-
});
557-
}
558-
559-
#[test]
560-
fn response_metadata_roundtrip() {
561-
roundtrip_test(ResponseMetadata {
562-
finish_reason: Some(FinishReason::Stop),
563-
usage: Some(Usage {
564-
input_tokens: Some(100),
565-
output_tokens: None,
566-
total_tokens: Some(100),
567-
}),
568-
provider_id: Some("provider_id".to_string()),
569-
timestamp: Some("2023-10-01T00:00:00Z".to_string()),
570-
provider_metadata_json: Some("{\"key\": \"value\"}".to_string()),
571-
});
572-
roundtrip_test(ResponseMetadata {
573-
finish_reason: None,
574-
usage: None,
575-
provider_id: None,
576-
timestamp: None,
577-
provider_metadata_json: None,
578-
});
579-
}
580-
581-
#[test]
582-
fn complete_response_roundtrip() {
583-
roundtrip_test(CompleteResponse {
584-
id: "response_id".to_string(),
585-
content: vec![
586-
ContentPart::Text("Hello".to_string()),
587-
ContentPart::Image(ImageReference::Url(ImageUrl {
588-
url: "https://example.com/image.png".to_string(),
589-
detail: Some(ImageDetail::High),
590-
})),
591-
],
592-
tool_calls: vec![ToolCall {
593-
id: "x".to_string(),
594-
name: "y".to_string(),
595-
arguments_json: "\"z\"".to_string(),
596-
}],
597-
metadata: ResponseMetadata {
598-
finish_reason: Some(FinishReason::Stop),
599-
usage: None,
600-
provider_id: None,
601-
timestamp: None,
602-
provider_metadata_json: None,
603-
},
604-
});
605-
}
606-
607-
#[test]
608-
fn chat_event_roundtrip() {
609-
roundtrip_test(ChatEvent::Message(CompleteResponse {
610-
id: "response_id".to_string(),
611-
content: vec![
612-
ContentPart::Text("Hello".to_string()),
613-
ContentPart::Image(ImageReference::Url(ImageUrl {
614-
url: "https://example.com/image.png".to_string(),
615-
detail: Some(ImageDetail::High),
616-
})),
617-
],
618-
tool_calls: vec![ToolCall {
619-
id: "x".to_string(),
620-
name: "y".to_string(),
621-
arguments_json: "\"z\"".to_string(),
622-
}],
623-
metadata: ResponseMetadata {
624-
finish_reason: Some(FinishReason::Stop),
625-
usage: None,
626-
provider_id: None,
627-
timestamp: None,
628-
provider_metadata_json: None,
629-
},
630-
}));
631-
roundtrip_test(ChatEvent::ToolRequest(vec![ToolCall {
632-
id: "x".to_string(),
633-
name: "y".to_string(),
634-
arguments_json: "\"z\"".to_string(),
635-
}]));
636-
roundtrip_test(ChatEvent::Error(Error {
637-
code: ErrorCode::InvalidRequest,
638-
message: "Invalid request".to_string(),
639-
provider_error_json: Some("Provider error".to_string()),
640-
}));
641-
}
642-
643-
#[test]
644-
fn send_input_encoding() {
645-
let input = SendInput {
646-
messages: vec![
647-
Message {
648-
role: Role::User,
649-
name: Some("user".to_string()),
650-
content: vec![ContentPart::Text("Hello".to_string())],
651-
},
652-
Message {
653-
role: Role::Assistant,
654-
name: None,
655-
content: vec![ContentPart::Image(ImageReference::Url(ImageUrl {
656-
url: "https://example.com/image.png".to_string(),
657-
detail: Some(ImageDetail::High),
658-
}))],
659-
},
660-
Message {
661-
role: Role::User,
662-
name: None,
663-
content: vec![
664-
ContentPart::Text("Analyze this image:".to_string()),
665-
ContentPart::Image(ImageReference::Inline(ImageSource {
666-
data: vec![0, 1, 2, 3, 4, 5],
667-
mime_type: "image/jpeg".to_string(),
668-
detail: None,
669-
})),
670-
],
671-
},
672-
],
673-
config: Config {
674-
model: "gpt-3.5-turbo".to_string(),
675-
temperature: Some(0.7),
676-
max_tokens: Some(100),
677-
stop_sequences: Some(vec!["\n".to_string()]),
678-
tools: vec![],
679-
tool_choice: None,
680-
provider_options: vec![],
681-
},
682-
};
683-
684-
let encoded = input.into_value_and_type();
685-
println!("{encoded:#?}");
686-
687-
for wit_type in encoded.typ.nodes {
688-
if let WitTypeNode::ListType(idx) = wit_type.type_ {
689-
assert!(idx >= 0);
690-
}
691-
}
692-
}
693-
}
694463
}

0 commit comments

Comments
 (0)