Module: ModelContextProtocol::Server::ContentHelpers
- Included in:
- Prompt, Prompt::MessageHistoryBuilder, Tool
- Defined in:
- lib/model_context_protocol/server/content_helpers.rb
Instance Method Summary collapse
- #audio_content(data:, mime_type:, meta: nil, annotations: {}) ⇒ Object
- #embedded_resource_content(resource:) ⇒ Object
- #image_content(data:, mime_type:, meta: nil, annotations: {}) ⇒ Object
- #resource_link(name:, uri:, meta: nil, annotations: {}, description: nil, mime_type: nil, size: nil, title: nil) ⇒ Object
- #text_content(text:, meta: nil, annotations: {}) ⇒ Object
Instance Method Details
#audio_content(data:, mime_type:, meta: nil, annotations: {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/model_context_protocol/server/content_helpers.rb', line 32 def audio_content(data:, mime_type:, meta: nil, annotations: {}) serialized_annotations = ModelContextProtocol::Server::Content::Annotations[ audience: annotations[:audience], last_modified: annotations[:last_modified], priority: annotations[:priority] ].serialized ModelContextProtocol::Server::Content::Audio[ meta:, annotations: serialized_annotations, data:, mime_type: ] end |
#embedded_resource_content(resource:) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/model_context_protocol/server/content_helpers.rb', line 47 def (resource:) extracted_resource = resource.serialized[:contents].first annotations = extracted_resource.key?(:annotations) ? extracted_resource.delete(:annotations) : {} serialized_annotations = ModelContextProtocol::Server::Content::Annotations[ audience: annotations[:audience], last_modified: annotations[:lastModified], priority: annotations[:priority] ].serialized extracted_resource[:annotations] = serialized_annotations if serialized_annotations ModelContextProtocol::Server::Content::EmbeddedResource[ meta: nil, resource: extracted_resource ] end |
#image_content(data:, mime_type:, meta: nil, annotations: {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/model_context_protocol/server/content_helpers.rb', line 17 def image_content(data:, mime_type:, meta: nil, annotations: {}) serialized_annotations = ModelContextProtocol::Server::Content::Annotations[ audience: annotations[:audience], last_modified: annotations[:last_modified], priority: annotations[:priority] ].serialized ModelContextProtocol::Server::Content::Image[ meta:, annotations: serialized_annotations, data:, mime_type: ] end |
#resource_link(name:, uri:, meta: nil, annotations: {}, description: nil, mime_type: nil, size: nil, title: nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/model_context_protocol/server/content_helpers.rb', line 65 def resource_link(name:, uri:, meta: nil, annotations: {}, description: nil, mime_type: nil, size: nil, title: nil) serialized_annotations = ModelContextProtocol::Server::Content::Annotations[ audience: annotations[:audience], last_modified: annotations[:last_modified], priority: annotations[:priority] ].serialized ModelContextProtocol::Server::Content::ResourceLink[ meta:, annotations: serialized_annotations, description:, mime_type:, name:, size:, title:, uri: ].serialized end |
#text_content(text:, meta: nil, annotations: {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/model_context_protocol/server/content_helpers.rb', line 3 def text_content(text:, meta: nil, annotations: {}) serialized_annotations = ModelContextProtocol::Server::Content::Annotations[ audience: annotations[:audience], last_modified: annotations[:last_modified], priority: annotations[:priority] ].serialized ModelContextProtocol::Server::Content::Text[ meta:, annotations: serialized_annotations, text: ] end |