{ "cells": [ { "cell_type": "markdown", "id": "66347c7d-869f-4d4d-8302-0e62459dc430", "metadata": {}, "source": [ "# A quick LangChain and Ollama demo." ] }, { "cell_type": "code", "execution_count": 2, "id": "b12e9493-f696-4a0e-bcf0-69a1cb4b829c", "metadata": {}, "outputs": [], "source": [ "!pip install -q langchain langchain-ollama" ] }, { "cell_type": "code", "execution_count": 7, "id": "229a7149-c90b-4ea4-ad9c-6b24a1250b13", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "This is a classic question from *Monty Python and the Holy Grail*! The answer, as famously delivered by King Arthur, is delightfully complicated:\n", "\n", "**\"What do you mean? An African or European swallow?\"**\n", "\n", "The joke is that there's no single answer. The airspeed velocity depends entirely on the type of swallow. \n", "\n", "* **European Swallow:** Roughly 11 meters per second (24 mph)\n", "* **African Swallow:** The film doesn't give a specific number, but it's implied to be faster.\n", "\n", "**Important Note:** The scene is entirely satirical and meant to be absurd. It's a running gag with no serious scientific basis.\n", "\n", "You can find more detailed breakdowns of the debate surrounding this question here: [https://en.wikipedia.org/wiki/Airspeed_velocity_of_an_unladen_swallow](https://en.wikipedia.org/wiki/Airspeed_velocity_of_an_unladen_swallow)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from langchain_ollama import OllamaLLM\n", "from IPython.display import display, Markdown\n", "\n", "llm = OllamaLLM(model=\"gemma3:4b\", temperature=\"0\")\n", "\n", "response = llm.invoke(\"What is the airspeed velocity of an unladen swallow?\")\n", "display(Markdown(response))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 5 }