From 36ca5eea1a5d4c266071d6a50848ad154034c44d Mon Sep 17 00:00:00 2001 From: William Guss Date: Thu, 21 Nov 2024 13:08:53 -0800 Subject: [PATCH] example of notebooks working --- examples/notebook.ipynb | 130 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 examples/notebook.ipynb diff --git a/examples/notebook.ipynb b/examples/notebook.ipynb new file mode 100644 index 00000000..57c8e520 --- /dev/null +++ b/examples/notebook.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import ell\n", + "ell.init(verbose=True, store='./logdir')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "╔══════════════════════════════════════════════════════════════════════════════╗\n", + "║ hello_world(world)\n", + "╠══════════════════════════════════════════════════════════════════════════════╣\n", + "║ Prompt:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ user: Say hello, world!\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "║ Output:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ assistant: Hello, world! 🌍\n", + "╚══════════════════════════════════════════════════════════════════════════════╝\n" + ] + }, + { + "data": { + "text/plain": [ + "'Hello, world! 🌍'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "@ell.simple(model=\"gpt-4o-mini\")\n", + "def hello_world(input_text: str):\n", + " return f\"Say hello, {input_text}!\"\n", + "\n", + "hello_world(\"world\")" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "╔══════════════════════════════════════════════════════════════════════════════╗\n", + "║ hello_world(world)\n", + "╠══════════════════════════════════════════════════════════════════════════════╣\n", + "║ Prompt:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ user: Say hello, world!\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "║ Output:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ assistant: Hello, world! 😊 How can I assist you today?\n", + "╚══════════════════════════════════════════════════════════════════════════════╝\n", + "╔══════════════════════════════════════════════════════════════════════════════╗\n", + "║ my_other_lmp(world)\n", + "╠══════════════════════════════════════════════════════════════════════════════╣\n", + "║ Prompt:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ user: Summarize Hello, world! 😊 How can I assist you today?\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "║ Output:\n", + "╟──────────────────────────────────────────────────────────────────────────────╢\n", + "│ assistant: \"Hello, world! 😊 How can I assist you today?\" is a\n", + "│ friendly greeting that expresses openness and willingness to\n", + "│ help.\n", + "╚══════════════════════════════════════════════════════════════════════════════╝\n" + ] + }, + { + "data": { + "text/plain": [ + "'\"Hello, world! 😊 How can I assist you today?\" is a friendly greeting that expresses openness and willingness to help.'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "@ell.simple(model=\"gpt-4o-mini\")\n", + "def sentiment(input_text: str):\n", + " return f\"assess the sentiment {hello_world(input_text)}\"\n", + "\n", + "my_other_lmp(\"world\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "ell-ai-lj28Ksf3-py3.12", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}