Module: LlmMetaClient::Helpers
- Includes:
- ChatManager::Helpers, PromptNavigator::Helpers
- Defined in:
- lib/llm_meta_client/helpers.rb
Constant Summary collapse
- ATTACHED_IMAGE_HEAD =
Pull a leading ‘` image off a user prompt so it can be rendered as a plain <img> while the remaining text stays plain. Returns [img_html_safe_or_nil, remaining_text]. Emits the tag directly (no markdown helper required) so this works in any host.
/\A!\[[^\]]*\]\(data:([^;]+);base64,([^\)]+)\)\s*\n*/m
Instance Method Summary collapse
Instance Method Details
#split_attached_image_html(text) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/llm_meta_client/helpers.rb', line 12 def split_attached_image_html(text) s = text.to_s m = s.match(ATTACHED_IMAGE_HEAD) return [ nil, s ] unless m img = tag.img( src: "data:#{m[1]};base64,#{m[2]}", alt: "", class: "user-attached-image" ) [ img, s.sub(ATTACHED_IMAGE_HEAD, "") ] end |