diff --git a/cookbook/liteLLM_Ollama.ipynb b/cookbook/liteLLM_Ollama.ipynb index b378558d2..7953972d9 100644 --- a/cookbook/liteLLM_Ollama.ipynb +++ b/cookbook/liteLLM_Ollama.ipynb @@ -10,34 +10,31 @@ "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", - "Requirement already satisfied: litellm==0.1.723 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (0.1.723)\n", - "Requirement already satisfied: importlib-metadata<7.0.0,>=6.8.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.723) (6.8.0)\n", - "Requirement already satisfied: openai<0.29.0,>=0.27.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.723) (0.28.0)\n", - "Requirement already satisfied: python-dotenv>=0.2.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.723) (1.0.0)\n", - "Requirement already satisfied: tiktoken<0.5.0,>=0.4.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.723) (0.4.0)\n", - "Requirement already satisfied: zipp>=0.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from importlib-metadata<7.0.0,>=6.8.0->litellm==0.1.723) (3.15.0)\n", - "Requirement already satisfied: requests>=2.20 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.723) (2.28.2)\n", - "Requirement already satisfied: tqdm in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.723) (4.65.0)\n", - "Requirement already satisfied: aiohttp in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.723) (3.8.4)\n", - "Requirement already satisfied: regex>=2022.1.18 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from tiktoken<0.5.0,>=0.4.0->litellm==0.1.723) (2023.6.3)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.723) (3.1.0)\n", - "Requirement already satisfied: idna<4,>=2.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.723) (3.4)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.723) (1.26.6)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.723) (2023.5.7)\n", - "Requirement already satisfied: attrs>=17.3.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (23.1.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (6.0.4)\n", - "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (4.0.2)\n", - "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (1.9.2)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (1.3.3)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.723) (1.3.1)\n", - "Defaulting to user installation because normal site-packages is not writeable\n", - "Requirement already satisfied: async_generator in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (1.10)\n" + "Requirement already satisfied: litellm==0.1.724 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (0.1.724)\n", + "Requirement already satisfied: importlib-metadata<7.0.0,>=6.8.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.724) (6.8.0)\n", + "Requirement already satisfied: openai<0.29.0,>=0.27.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.724) (0.28.0)\n", + "Requirement already satisfied: python-dotenv>=0.2.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.724) (1.0.0)\n", + "Requirement already satisfied: tiktoken<0.5.0,>=0.4.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from litellm==0.1.724) (0.4.0)\n", + "Requirement already satisfied: zipp>=0.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from importlib-metadata<7.0.0,>=6.8.0->litellm==0.1.724) (3.15.0)\n", + "Requirement already satisfied: requests>=2.20 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.724) (2.28.2)\n", + "Requirement already satisfied: tqdm in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.724) (4.65.0)\n", + "Requirement already satisfied: aiohttp in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from openai<0.29.0,>=0.27.0->litellm==0.1.724) (3.8.4)\n", + "Requirement already satisfied: regex>=2022.1.18 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from tiktoken<0.5.0,>=0.4.0->litellm==0.1.724) (2023.6.3)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.724) (3.1.0)\n", + "Requirement already satisfied: idna<4,>=2.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.724) (3.4)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.724) (1.26.6)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from requests>=2.20->openai<0.29.0,>=0.27.0->litellm==0.1.724) (2023.5.7)\n", + "Requirement already satisfied: attrs>=17.3.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (23.1.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (6.0.4)\n", + "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (4.0.2)\n", + "Requirement already satisfied: yarl<2.0,>=1.0 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (1.9.2)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (1.3.3)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (from aiohttp->openai<0.29.0,>=0.27.0->litellm==0.1.724) (1.3.1)\n" ] } ], "source": [ - "!pip install litellm==0.1.723\n", - "!pip install async_generator" + "!pip install litellm # version 0.1.724 or higher " ] }, { @@ -45,7 +42,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Call Ollama - llama2" + "## Call Ollama - llama2 with Streaming" ] }, { @@ -57,9 +54,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "\n", + "\n", "{'role': 'assistant', 'content': ' I'}\n", - "{'role': 'assistant', 'content': ' am'}\n", + "{'role': 'assistant', 'content': \"'\"}\n", + "{'role': 'assistant', 'content': 'm'}\n", "{'role': 'assistant', 'content': ' L'}\n", "{'role': 'assistant', 'content': 'La'}\n", "{'role': 'assistant', 'content': 'MA'}\n", @@ -96,7 +94,7 @@ "response = completion(\n", " model=\"ollama/llama2\", \n", " messages=[{ \"content\": \"respond in 20 words. who are you?\",\"role\": \"user\"}], \n", - " api_base=\"http://localhost:11434\", \n", + " api_base=\"http://localhost:11434\",\n", " stream=True\n", ")\n", "print(response)\n", @@ -114,7 +112,26 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Defaulting to user installation because normal site-packages is not writeable\n", + "Requirement already satisfied: async_generator in /Users/ishaanjaffer/Library/Python/3.9/lib/python/site-packages (1.10)\n" + ] + } + ], + "source": [ + "# litellm uses async_generator for ollama async streaming, ensure it's installed\n", + "!pip install async_generator" + ] + }, + { + "cell_type": "code", + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -122,16 +139,13 @@ "output_type": "stream", "text": [ "{'choices': [{'delta': {'role': 'assistant', 'content': ' I'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' am'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' a'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' text'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': '-'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': 'based'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': \"'\"}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': 'm'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' just'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' an'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' A'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': 'I'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' language'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' model'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' and'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ','}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' I'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' don'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': \"'\"}}]}\n", @@ -144,71 +158,53 @@ "{'choices': [{'delta': {'role': 'assistant', 'content': 'time'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' weather'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' information'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': '.'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': 'ℝ'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' However'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ','}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' I'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' can'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' tell'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' you'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' the'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' or'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' current'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' weather'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' conditions'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' for'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' a'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' in'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' your'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' specific'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' location'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': '.'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' живело'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' can'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' provide'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' you'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' with'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' weather'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' forec'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': 'asts'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' and'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' information'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' for'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' your'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' location'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' if'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' you'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' provide'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' me'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' with'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' the'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' city'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' or'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' zip'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' code'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' would'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' like'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': '.'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' Alternatively'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ','}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' Please'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' let'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' me'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' know'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' where'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' you'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' are'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' located'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ','}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' and'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' I'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' will'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' do'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' my'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' best'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' to'}}]}\n", + "{'choices': [{'delta': {'role': 'assistant', 'content': ' assist'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': ' you'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' can'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' check'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' the'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' weather'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' for'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' any'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' location'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' in'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' the'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' world'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' by'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' using'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' a'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' search'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' engine'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' or'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' visit'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': 'ing'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' a'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' weather'}}]}\n", - "{'choices': [{'delta': {'role': 'assistant', 'content': ' website'}}]}\n", "{'choices': [{'delta': {'role': 'assistant', 'content': '.'}}]}\n", "None\n" ] - }, - { - "ename": "TypeError", - "evalue": "'async for' requires an object with __aiter__ method, got NoneType", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[4], line 15\u001b[0m\n\u001b[1;32m 13\u001b[0m result \u001b[39m=\u001b[39m \u001b[39mawait\u001b[39;00m async_ollama()\n\u001b[1;32m 14\u001b[0m \u001b[39mprint\u001b[39m(result)\n\u001b[0;32m---> 15\u001b[0m \u001b[39masync\u001b[39;00m \u001b[39mfor\u001b[39;00m chunk \u001b[39min\u001b[39;00m result:\n\u001b[1;32m 16\u001b[0m \u001b[39mprint\u001b[39m(chunk)\n", - "\u001b[0;31mTypeError\u001b[0m: 'async for' requires an object with __aiter__ method, got NoneType" - ] } ], "source": [ @@ -226,8 +222,66 @@ "\n", "result = await async_ollama()\n", "print(result)\n", - "async for chunk in result:\n", - " print(chunk)" + "\n", + "try:\n", + " async for chunk in result:\n", + " print(chunk)\n", + "except TypeError: # the last chunk is None from Ollama, this raises an error with async streaming\n", + " pass" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Completion Call" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"object\": \"chat.completion\",\n", + " \"choices\": [\n", + " {\n", + " \"finish_reason\": \"stop\",\n", + " \"index\": 0,\n", + " \"message\": {\n", + " \"content\": \" I'm LLaMA, an AI assistant developed by Meta AI that can understand and respond to human input in a conversational manner.\",\n", + " \"role\": \"assistant\",\n", + " \"logprobs\": null\n", + " }\n", + " }\n", + " ],\n", + " \"id\": \"chatcmpl-ea7b8242-791f-4656-ba12-e098edeb960e\",\n", + " \"created\": 1695324686.6696231,\n", + " \"response_ms\": 4072.3050000000003,\n", + " \"model\": \"ollama/llama2\",\n", + " \"usage\": {\n", + " \"prompt_tokens\": 10,\n", + " \"completion_tokens\": 27,\n", + " \"total_tokens\": 37\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "from litellm import completion\n", + "\n", + "response = completion(\n", + " model=\"ollama/llama2\", \n", + " messages=[{ \"content\": \"respond in 20 words. who are you?\",\"role\": \"user\"}], \n", + " api_base=\"http://localhost:11434\"\n", + ")\n", + "print(response)\n" ] }, {