Spaces:
Runtime error
Runtime error
File size: 5,345 Bytes
9ec63d3 |
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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to the start of your adventure in Agentic AI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### And please do remember to contact me if I can help\n",
"\n",
"And I love to connect: https://www.linkedin.com/in/eddonner/\n",
"\n",
"\n",
"### New to Notebooks like this one? Head over to the guides folder!\n",
"\n",
"Just to check you've already added the Python and Jupyter extensions to Cursor, if not already installed:\n",
"- Open extensions (View >> extensions)\n",
"- Search for python, and when the results show, click on the ms-python one, and Install it if not already installed\n",
"- Search for jupyter, and when the results show, click on the Microsoft one, and Install it if not already installed \n",
"Then View >> Explorer to bring back the File Explorer.\n",
"\n",
"And then:\n",
"1. Click where it says \"Select Kernel\" near the top right, and select the option called `.venv (Python 3.12.9)` or similar, which should be the first choice or the most prominent choice. You may need to choose \"Python Environments\" first.\n",
"2. Click in each \"cell\" below, starting with the cell immediately below this text, and press Shift+Enter to run\n",
"3. Enjoy!\n",
"\n",
"After you click \"Select Kernel\", if there is no option like `.venv (Python 3.12.9)` then please do the following: \n",
"1. On Mac: From the Cursor menu, choose Settings >> VS Code Settings (NOTE: be sure to select `VSCode Settings` not `Cursor Settings`); \n",
"On Windows PC: From the File menu, choose Preferences >> VS Code Settings(NOTE: be sure to select `VSCode Settings` not `Cursor Settings`) \n",
"2. In the Settings search bar, type \"venv\" \n",
"3. In the field \"Path to folder with a list of Virtual Environments\" put the path to the project root, like C:\\Users\\username\\projects\\agents (on a Windows PC) or /Users/username/projects/agents (on Mac or Linux). \n",
"And then try again.\n",
"\n",
"Having problems with missing Python versions in that list? Have you ever used Anaconda before? It might be interferring. Quit Cursor, bring up a new command line, and make sure that your Anaconda environment is deactivated: \n",
"`conda deactivate` \n",
"And if you still have any problems with conda and python versions, it's possible that you will need to run this too: \n",
"`conda config --set auto_activate_base false` \n",
"and then from within the Agents directory, you should be able to run `uv python list` and see the Python 3.12 version."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from dotenv import load_dotenv\n",
"load_dotenv()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Check the keys\n",
"import google.generativeai as genai\n",
"import os\n",
"genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))\n",
"model = genai.GenerativeModel(model_name=\"gemini-1.5-flash\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create a list of messages in the familiar Gemini GenAI format\n",
"\n",
"response = model.generate_content([\"2+2=?\"])\n",
"response.text"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# And now - let's ask for a question:\n",
"\n",
"question = \"Please propose a hard, challenging question to assess someone's IQ. Respond only with the question.\"\n",
"\n",
"response = model.generate_content([question])\n",
"print(response.text)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import Markdown, display\n",
"\n",
"display(Markdown(response.text))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Congratulations!\n",
"\n",
"That was a small, simple step in the direction of Agentic AI, with your new environment!\n",
"\n",
"Next time things get more interesting..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# First create the messages:\n",
"\n",
"messages = [{\"role\": \"user\", \"content\": \"Something here\"}]\n",
"\n",
"# Then make the first call:\n",
"\n",
"response =\n",
"\n",
"# Then read the business idea:\n",
"\n",
"business_idea = response.\n",
"\n",
"# And repeat!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "llm_projects",
"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.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|