Download crates/forge_app/src/set_conversation_id.rs from SaylorTwift/forgecode: direct link, hf CLI and curl.
- Browser
- Download file 971 Bytes
-
https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_app/src/set_conversation_id.rs
- Command line
-
hf download hf://SaylorTwift/forgecode/crates/forge_app/src/set_conversation_id.rs
-
curl -L -o set_conversation_id.rs https://huggingface.co/SaylorTwift/forgecode/resolve/main/crates/forge_app/src/set_conversation_id.rs
971 Bytes
| use forge_domain::Conversation; | |
| /// Sets the conversation_id on the conversation context | |
| pub struct SetConversationId; | |
| impl SetConversationId { | |
| pub fn apply(self, mut conversation: Conversation) -> Conversation { | |
| let ctx = conversation | |
| .context | |
| .take() | |
| .unwrap_or_default() | |
| .conversation_id(conversation.id); | |
| conversation.context(ctx) | |
| } | |
| } | |
| mod tests { | |
| use forge_domain::{Context, ConversationId}; | |
| use pretty_assertions::assert_eq; | |
| use super::*; | |
| fn test_sets_conversation_id() { | |
| let conversation_id = ConversationId::generate(); | |
| let conversation = Conversation::new(conversation_id).context(Context::default()); | |
| let actual = SetConversationId.apply(conversation); | |
| assert_eq!( | |
| actual.context.unwrap().conversation_id, | |
| Some(conversation_id) | |
| ); | |
| } | |
| } | |