{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Stop program
Tweak this proverb to apply to model instructions instead.\n",
       "\n",
       "Where there is no guidance, a people falls,\n",
       "but in an abundance of counselors there is safety.\n",
       "- Proverbs 11:14\n",
       "\n",
       "UPDATED\n",
       "Where there is no guidance for assembling a model, people will struggle,\n",
       "but with clear instructions, the process becomes safe and successful.\n",
       "- GPT 2 (updated): Proverbs 11:14
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import os\n", "\n", "os.environ[\"OPENAI_API_KEY\"] = \"sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" # can be anything\n", "os.environ[\"OPENAI_API_BASE\"] = \"http://100.64.159.73:8000/v1\"\n", "os.environ[\"OPENAI_API_HOST\"] = \"http://100.64.159.73:8000\"\n", "\n", "import guidance\n", "\n", "# set the default language model used to execute guidance programs\n", "guidance.llm = guidance.llms.OpenAI(\"text-davinci-003\", caching=False)\n", "\n", "# define a guidance program that adapts a proverb\n", "program = guidance(\"\"\"Tweak this proverb to apply to model instructions instead.\n", "\n", "{{proverb}}\n", "- {{book}} {{chapter}}:{{verse}}\n", "\n", "UPDATED\n", "Where there is no guidance{{gen 'rewrite' stop=\"\\\\n-\"}}\n", "- GPT {{gen 'chapter'}}:{{gen 'verse'}}\"\"\")\n", "\n", "# execute the program on a specific proverb\n", "executed_program = program(\n", " proverb=\"Where there is no guidance, a people falls,\\nbut in an abundance of counselors there is safety.\",\n", " book=\"Proverbs\",\n", " chapter=11,\n", " verse=14\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.8.10" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }