File size: 4,508 Bytes
e39ab22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "! pip install -q --upgrade google-generativeai langchain-google-genai"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from dotenv import load_dotenv\n",
    "load_dotenv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vasim/.local/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "from langchain_google_genai import ChatGoogleGenerativeAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import display\n",
    "from IPython.display import Markdown\n",
    "import textwrap\n",
    "\n",
    "\n",
    "def to_markdown(text):\n",
    "  text = text.replace('•', '  *')\n",
    "  return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "> 1. **Exercise Regularly:** Aim for at least 150 minutes of moderate-intensity aerobic activity (e.g., brisk walking, cycling, swimming) or 75 minutes of vigorous-intensity aerobic activity (e.g., running, circuit training) each week.\n",
       "> 2. **Strength Training:** Incorporate strength training exercises that work all major muscle groups at least twice a week. This helps build and maintain muscle mass, which improves strength, mobility, and bone density.\n",
       "> 3. **Mindful Eating:** Pay attention to hunger and fullness cues. Eat a balanced diet rich in fruits, vegetables, whole grains, lean protein, and healthy fats. Avoid processed foods, excessive sugar, and large portion sizes.\n",
       "> 4. **Good Sleep:** Aim for 7-8 hours of quality sleep each night. Sleep helps the body recover from exercise, regulates hormones, and supports overall well-being.\n",
       "> 5. **Manage Stress:** Engage in stress management practices such as meditation, yoga, deep breathing, or spending time in nature. Chronic stress can negatively impact physical and mental health.\n",
       "> 6. **Avoid Smoking and Excessive Alcohol:** Smoking is detrimental to overall health. Excessive alcohol consumption can interfere with sleep, lead to weight gain, and increase the risk of liver damage.\n",
       "> 7. **Stay Hydrated:** Drinking plenty of water is essential for various bodily functions. Dehydration can lead to fatigue and impaired performance.\n",
       "> 8. **Routine Medical Check-ups:** Schedule regular check-ups with your healthcare provider to monitor your overall health, including blood pressure, cholesterol, and weight.\n",
       "> 9. **Body Positivity:** Focus on feeling healthy and strong rather than obsessing over appearance. Appreciate your body for its abilities and prioritize health over unattainable beauty standards.\n",
       "> 10. **Find Enjoyable Activities:** Choose physical activities that you genuinely enjoy. This makes it more likely that you'll stick with your fitness routine over time."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "llm = ChatGoogleGenerativeAI(model=\"gemini-pro\")\n",
    "result = llm.invoke(\"What is the best practice to keep fit?\")\n",
    "to_markdown(result.content)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}