Created
June 27, 2025 20:02
-
-
Save luisquintanilla/bb1876bf2385213d83594d2c65e15e73 to your computer and use it in GitHub Desktop.
Where's Waldo? AI Edition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "ea2d3e06", | |
| "metadata": { | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelName": "csharp" | |
| } | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>Azure.AI.OpenAI, 2.2.0-beta.4</span></li><li><span>Azure.Identity, 1.14.1</span></li><li><span>Microsoft.Extensions.AI, 9.6.0</span></li><li><span>Microsoft.Extensions.AI.OpenAI, 9.6.0-preview.1.25310.2</span></li><li><span>OllamaSharp, 5.2.3</span></li></ul></div></div>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "#r \"nuget: OllamaSharp, 5.2.3\"\n", | |
| "#r \"nuget: Microsoft.Extensions.AI, 9.6.0\"\n", | |
| "#r \"nuget: Microsoft.Extensions.AI.OpenAI, 9.6.0-preview.1.25310.2\"\n", | |
| "#r \"nuget: Azure.AI.OpenAI, 2.2.0-beta.4\"\n", | |
| "#r \"nuget: Azure.Identity, 1.14.1\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "id": "37d83a68", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "using OllamaSharp;\n", | |
| "using Azure.AI.OpenAI;\n", | |
| "using Azure;\n", | |
| "using Azure.Identity;\n", | |
| "using Microsoft.Extensions.AI;" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "8b7f44d0", | |
| "metadata": {}, | |
| "source": [ | |
| "## Where's Waldo?\n", | |
| "\n", | |
| "" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "id": "8efc0d32", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "List<AIContent> messages = \n", | |
| " [\n", | |
| " new TextContent(\"Look at this image and tell me where Waldo is\"),\n", | |
| " new UriContent(\"https://i.imgur.com/OTfytjA.jpeg\", \"image/jpeg\")\n", | |
| " ];" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "8ebd5c3f", | |
| "metadata": {}, | |
| "source": [ | |
| "## Ollama" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "id": "118d96a8", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "IChatClient ollamaClient = new OllamaApiClient(\"http://localhost:11434\", \"gemma3n\");" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "id": "054fa1c5", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "var ollamaRes = await ollamaClient.GetResponseAsync(new ChatMessage(ChatRole.User,messages));" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "id": "0764cce6", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Okay, I've examined the image! \n", | |
| "\n", | |
| "Waldo is hiding in the **upper right quadrant of the image**. He's wearing his iconic red and white striped shirt and hat, and he's standing near a group of people. \n", | |
| "\n", | |
| "Let me know if you'd like me to try and pinpoint him more precisely! 😊 \n" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "ollamaRes.Text" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "63b084a4", | |
| "metadata": {}, | |
| "source": [ | |
| "## OpenAI" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "id": "fdab2bed", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "IChatClient openAIClient = \n", | |
| " new AzureOpenAIClient(new Uri(Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\")), new DefaultAzureCredential())\n", | |
| " .GetChatClient(\"gpt-4.1\")\n", | |
| " .AsIChatClient();" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "id": "46701b32", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "var openAIRes = await openAIClient.GetResponseAsync(new ChatMessage(ChatRole.User,messages));" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "id": "32889654", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Waldo is located just to the right of the center of the image. He is standing behind a table with items on it, facing towards us. He is wearing his signature red and white striped shirt, hat, and glasses. If you look at the largest cluster of people near the middle, Waldo is just right of that area, in front of a person wearing yellow." | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "openAIRes.Text" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": ".NET (C#)", | |
| "language": "C#", | |
| "name": ".net-csharp" | |
| }, | |
| "language_info": { | |
| "name": "polyglot-notebook" | |
| }, | |
| "polyglot_notebook": { | |
| "kernelInfo": { | |
| "defaultKernelName": "csharp", | |
| "items": [ | |
| { | |
| "aliases": [], | |
| "languageName": "csharp", | |
| "name": "csharp" | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment