From d6a723c6708231d96c28c18cf424640d72e59685 Mon Sep 17 00:00:00 2001 From: shubhirajMsft <114693979+shubhirajMsft@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:03:52 -0700 Subject: [PATCH] Multimodal Update cohere-embed.ipynb (#3425) * Multimodal Update cohere-embed.ipynb * Reformatted --- .../cohere/cohere-embed.ipynb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sdk/python/foundation-models/cohere/cohere-embed.ipynb b/sdk/python/foundation-models/cohere/cohere-embed.ipynb index 15f68d00a56..453486c6600 100644 --- a/sdk/python/foundation-models/cohere/cohere-embed.ipynb +++ b/sdk/python/foundation-models/cohere/cohere-embed.ipynb @@ -105,6 +105,35 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For image inputs you can try:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import base64\n", + "\n", + "# Open the image file in binary mode\n", + "with open(\"\", \"rb\") as image_file:\n", + " # Read the image data\n", + " image_data = image_file.read()\n", + "\n", + " # Encode the image data to base64\n", + " base64_encoded_data = base64.b64encode(image_data)\n", + "\n", + " # Convert the base64 bytes to a string\n", + " base64_string = base64_encoded_data.decode(\"utf-8\")\n", + "\n", + "co.embed(images=[base64_string], input_type=\"image\")" + ] + }, { "cell_type": "markdown", "metadata": {},