(info: &MessageInfo, parts: &[Part])
| 1539 | } |
| 1540 | |
| 1541 | fn message_to_model(info: &MessageInfo, parts: &[Part]) -> Option<Message> { |
| 1542 | let role = match info { |
| 1543 | MessageInfo::User { .. } => opencode_provider::Role::User, |
| 1544 | MessageInfo::Assistant { .. } => opencode_provider::Role::Assistant, |
| 1545 | }; |
| 1546 | |
| 1547 | let content = if parts.len() == 1 { |
| 1548 | match &parts[0] { |
| 1549 | Part::Text { text, .. } => Content::Text(text.clone()), |
| 1550 | _ => Content::Parts(parts.iter().filter_map(part_to_content_part).collect()), |
| 1551 | } |
| 1552 | } else { |
| 1553 | Content::Parts(parts.iter().filter_map(part_to_content_part).collect()) |
| 1554 | }; |
| 1555 | |
| 1556 | Some(Message { |
| 1557 | role, |
| 1558 | content, |
| 1559 | cache_control: None, |
| 1560 | provider_options: None, |
| 1561 | }) |
| 1562 | } |
| 1563 | |
| 1564 | fn part_to_content_part(part: &Part) -> Option<opencode_provider::ContentPart> { |
| 1565 | match part { |
no test coverage detected