diff --git a/community-contributions/Prashanth/Week 1/day1_test_pollama.ipynb b/community-contributions/Prashanth/Week 1/day1_test_pollama.ipynb new file mode 100644 index 0000000..6249589 --- /dev/null +++ b/community-contributions/Prashanth/Week 1/day1_test_pollama.ipynb @@ -0,0 +1,166 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 9, + "id": "638fc220-1cf5-49d8-a3c6-d425c759cd05", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠋ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠙ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠹ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠸ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠼ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠴ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠦ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠧ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠇ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest � \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠋ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest \u001b[K\n", + "pulling dde5aa3fc5ff: 100% ▕██████████████████� 2.0 GB \u001b[K\n", + "pulling 966de95ca8a6: 100% ▕██████████████████� 1.4 KB \u001b[K\n", + "pulling fcc5a6bec9da: 100% ▕██████████████████� 7.7 KB \u001b[K\n", + "pulling a70ff7e570d9: 100% ▕██████████████████� 6.0 KB \u001b[K\n", + "pulling 56bb8bd477a5: 100% ▕██████████████████� 96 B \u001b[K\n", + "pulling 34bb5ab01051: 100% ▕██████████████████� 561 B \u001b[K\n", + "verifying sha256 digest \u001b[K\n", + "writing manifest \u001b[K\n", + "success \u001b[K\u001b[?25h\u001b[?2026l\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ChatCompletion(id='chatcmpl-238', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1758556881, model='llama3.2', object='chat.completion', service_tier=None, system_fingerprint='fp_ollama', usage=CompletionUsage(completion_tokens=1, prompt_tokens=36, total_tokens=37, completion_tokens_details=None, prompt_tokens_details=None))\n" + ] + } + ], + "source": [ + "# openai = OpenAI()\n", + "# You need to do this one time on your computer\n", + "!ollama pull llama3.2\n", + "\n", + "# from openai import OpenAI\n", + "# MODEL = \"llama3.2\"\n", + "# openai = OpenAI(base_url=\"http://localhost:11434/v1\", api_key=\"ollama\")\n", + "\n", + "# response = openai.chat.completions.create(\n", + "# model=MODEL,\n", + "# messages=[{\"role\": \"system\", \"content\": \"Respond concisely, use bullet points\"},{\"role\": \"user\", \"content\": \"give information about a proper diet\"}]\n", + "# )\n", + "\n", + "# print(response.choices[0].message.content)\n", + "# print(response)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1fdff8c6-6a30-4cfa-aa59-385737af9536", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "Here are key points about a proper diet:\n", + "\n", + "**General Guidelines**\n", + "\n", + "* Focus on whole, unprocessed foods\n", + "* Include a variety of colors and food groups\n", + "* Aim for balance and moderation\n", + "\n", + "**Food Groups**\n", + "\n", + "* **Fruits**:\n", + "\t+ 2-3 servings a day (fresh, frozen, canned)\n", + "\t+ Include berries, citrus fruits, and stone fruits\n", + "* **Vegetables**:\n", + "\t+ 5-7 servings a day (fresh, frozen, canned)\n", + "\t+ Include dark leafy greens, bell peppers, carrots, and tomatoes\n", + "* **Protein**:\n", + "\t+ 2-3 servings a day (lean meats, fish, eggs, dairy, legumes)\n", + "\t+ Choose whole grains over refined protein sources\n", + "* **Whole Grains**:\n", + "\t+ 6-8 servings a day (brown rice, quinoa, whole wheat, oats)\n", + "\t+ Choose whole grain breads, pasta, and cereals\n", + "* **Dairy/Calcium**:\n", + "\t+ 2-3 servings a day (milk, cheese, yogurt)\n", + "\t+ Choose low-fat or fat-free options\n", + "* **Healthy Fats**:\n", + "\t+ Nuts and seeds (almonds, walnuts, chia seeds)\n", + "\t+ Avocados (1-2 servings a week)\n", + "\n", + "**Additional Tips**\n", + "\n", + "* Limit sugary drinks and added sugars\n", + "* Aim for 8 cups of water a day\n", + "* Incorporate healthy snacks, such as fruits, nuts, and carrot sticks with hummus\n", + "* Cook at home using fresh ingredients and minimal added oils\n", + "* Be mindful of portion sizes and calorie intake\n", + "\n", + "**Dietary Restrictions**\n", + "\n", + "* Consider vegan, vegetarian, gluten-free or low-carb diets if necessary\n", + "* Consult a healthcare professional or registered dietitian for personalized guidance" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from openai import OpenAI\n", + "MODEL = \"llama3.2\"\n", + "from IPython.display import Markdown, display\n", + "openai = OpenAI(base_url=\"http://localhost:11434/v1\", api_key=\"ollama\")\n", + "\n", + "response = openai.chat.completions.create(\n", + " model=MODEL,\n", + " messages=[{\"role\": \"system\", \"content\": \"Respond concisely, use bullet points\"},{\"role\": \"user\", \"content\": \"give information about a proper diet\"}]\n", + ")\n", + "\n", + "# print(response.choices[0].message.content)\n", + "# print(response)\n", + "\n", + "display(Markdown(response.choices[0].message.content))\n", + "# print(response.choices[0].message.content)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "075f490e-2a66-42b2-afa1-84e9ccaf5b77", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6524ce52-dfbc-453b-9871-185d5f9a9d04", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.11.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/community-contributions/day1_test_pollama.ipynb b/community-contributions/day1_test_pollama.ipynb index c5da23e..d43a372 100644 --- a/community-contributions/day1_test_pollama.ipynb +++ b/community-contributions/day1_test_pollama.ipynb @@ -23,9 +23,92 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "638fc220-1cf5-49d8-a3c6-d425c759cd05", "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠋ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠙ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠹ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠸ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠼ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠴ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠦ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠧ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠇ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest � \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest ⠋ \u001b[K\u001b[?25h\u001b[?2026l\u001b[?2026h\u001b[?25l\u001b[1Gpulling manifest \u001b[K\n", + "pulling dde5aa3fc5ff: 100% ▕██████████████████� 2.0 GB \u001b[K\n", + "pulling 966de95ca8a6: 100% ▕██████████████████� 1.4 KB \u001b[K\n", + "pulling fcc5a6bec9da: 100% ▕██████████████████� 7.7 KB \u001b[K\n", + "pulling a70ff7e570d9: 100% ▕██████████████████� 6.0 KB \u001b[K\n", + "pulling 56bb8bd477a5: 100% ▕██████████████████� 96 B \u001b[K\n", + "pulling 34bb5ab01051: 100% ▕██████████████████� 561 B \u001b[K\n", + "verifying sha256 digest \u001b[K\n", + "writing manifest \u001b[K\n", + "success \u001b[K\u001b[?25h\u001b[?2026l\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ChatCompletion(id='chatcmpl-238', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1758556881, model='llama3.2', object='chat.completion', service_tier=None, system_fingerprint='fp_ollama', usage=CompletionUsage(completion_tokens=1, prompt_tokens=36, total_tokens=37, completion_tokens_details=None, prompt_tokens_details=None))\n" + ] + } + ], + "source": [ + "# openai = OpenAI()\n", + "# You need to do this one time on your computer\n", + "!ollama pull llama3.2\n", + "\n", + "from openai import OpenAI\n", + "MODEL = \"llama3.2\"\n", + "openai = OpenAI(base_url=\"http://localhost:11434/v1\", api_key=\"ollama\")\n", + "\n", + "response = openai.chat.completions.create(\n", + " model=MODEL,\n", + " messages=[{\"role\": \"system\", \"content\": \"you are a wierd assistant\"},{\"role\": \"user\", \"content\": \"What is 2 + 2?\"}]\n", + ")\n", + "\n", + "# print(response.choices[0].message.content)\n", + "print(response)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1fdff8c6-6a30-4cfa-aa59-385737af9536", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "*whispers* The answer, much like my existence, is hidden in the shadows. But if I must reveal it to you... *clears throat* It's... 4.\n" + ] + } + ], + "source": [ + "response = openai.chat.completions.create(\n", + " model=MODEL,\n", + " messages=[{\"role\": \"system\", \"content\": \"you are a wierd assistant\"},{\"role\": \"user\", \"content\": \"What is 2 + 2?\"}]\n", + ")\n", + "\n", + "# print(response.choices[0].message.content)\n", + "# print(response)\n", + "\n", + "\n", + "print(response.choices[0].message.content)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "075f490e-2a66-42b2-afa1-84e9ccaf5b77", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6524ce52-dfbc-453b-9871-185d5f9a9d04", + "metadata": {}, "outputs": [], "source": [] }