From 46e79fed4fcd960277ac93453ea8dc3c64e2fc06 Mon Sep 17 00:00:00 2001 From: Anton Kulaga Date: Wed, 20 Nov 2024 18:34:10 +0100 Subject: [PATCH] Created using Colab --- .../notebooks/02_sqlite_example.ipynb | 1004 +++++++++++++++++ 1 file changed, 1004 insertions(+) create mode 100644 just_agents_examples/notebooks/02_sqlite_example.ipynb diff --git a/just_agents_examples/notebooks/02_sqlite_example.ipynb b/just_agents_examples/notebooks/02_sqlite_example.ipynb new file mode 100644 index 0000000..8610539 --- /dev/null +++ b/just_agents_examples/notebooks/02_sqlite_example.ipynb @@ -0,0 +1,1004 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Building your Own SQL Agent with Just-Agents ##\n" + ], + "metadata": { + "id": "9k4Gkr9gsMbA" + } + }, + { + "cell_type": "markdown", + "source": [ + "This notebook provides a comprehensive guide on how to create and utilize your own custom SQL agents using [just-agents](https://github.com/longevity-genie/just-agents/) library." + ], + "metadata": { + "id": "g7MwnE7rsYHR" + } + }, + { + "cell_type": "markdown", + "source": [ + "It is the second tutorial in a series of tutorials, next ones are:\n", + "1. Basic agents tutorial https://colab.research.google.com/drive/1l_pdfT0FhlzFzNV792xdiMD3xt0I660z\n", + "2. Database agent tutorial (THIS ONE) https://colab.research.google.com/drive/1FQGOfIytET5HlExxu4jdXHeOMJJDL0yg\n", + "3. Coding agent tutorial https://colab.research.google.com/drive/1CbqwSwUHir6VpWA0uKVIiqlZo6m2s6qm#scrollTo=xMh-QD4m8F7V" + ], + "metadata": { + "id": "LsvSImpG9nlO" + } + }, + { + "cell_type": "markdown", + "source": [ + "## Working with the Open-Genes Database\n", + "\n", + "For this tutorial, we'll be interacting with the Open-Genes database. We'll be using a simplified version stored in an SQLite file. You can access the original database file at:\n", + "\n", + "[https://github.com/longevity-genie/longevity_gpts/blob/main/open_genes/data/open_genes.sqlite](https://github.com/longevity-genie/longevity_gpts/blob/main/open_genes/data/open_genes.sqlite)" + ], + "metadata": { + "id": "kk20e41DnDCd" + } + }, + { + "cell_type": "markdown", + "source": [ + "Let's download the database first" + ], + "metadata": { + "id": "kFnEB8vYsVcY" + } + }, + { + "source": [ + "!wget https://github.com/longevity-genie/longevity_gpts/raw/main/open_genes/data/open_genes.sqlite -O open_genes.sqlite" + ], + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "u8pafg11rt4U", + "outputId": "6970185a-c9b7-460c-f2ff-ccf2a6143cde", + "collapsed": true + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "--2024-11-14 16:30:21-- https://github.com/longevity-genie/longevity_gpts/raw/main/open_genes/data/open_genes.sqlite\n", + "Resolving github.com (github.com)... 140.82.113.4\n", + "Connecting to github.com (github.com)|140.82.113.4|:443... connected.\n", + "HTTP request sent, awaiting response... 302 Found\n", + "Location: https://raw.githubusercontent.com/longevity-genie/longevity_gpts/main/open_genes/data/open_genes.sqlite [following]\n", + "--2024-11-14 16:30:21-- https://raw.githubusercontent.com/longevity-genie/longevity_gpts/main/open_genes/data/open_genes.sqlite\n", + "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n", + "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.\n", + "HTTP request sent, awaiting response... 200 OK\n", + "Length: 1150976 (1.1M) [application/octet-stream]\n", + "Saving to: ‘open_genes.sqlite’\n", + "\n", + "open_genes.sqlite 100%[===================>] 1.10M --.-KB/s in 0.06s \n", + "\n", + "2024-11-14 16:30:21 (18.4 MB/s) - ‘open_genes.sqlite’ saved [1150976/1150976]\n", + "\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "Let's test the query by outputing the tables" + ], + "metadata": { + "id": "6Lr5wHHgyA2M" + } + }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "q3UBwhdyz0X0" + } + }, + { + "cell_type": "code", + "source": [ + "import sqlite3\n", + "\n", + "def db_query(sql: str):\n", + " \"\"\" This function execute query on open-genes sqlite table. It returns query results. \"\"\"\n", + " conn = sqlite3.connect(\"open_genes.sqlite\")\n", + " cursor = conn.cursor()\n", + "\n", + " cursor.execute(sql)\n", + " try:\n", + " rows = cursor.fetchall()\n", + " if rows is None or len(rows) == 0:\n", + " conn.close()\n", + " return \"\"\n", + " names = [description[0] for description in cursor.description]\n", + " text = \"; \".join(names) + \"\\n\"\n", + " for row in rows:\n", + " row = [str(i) for i in row]\n", + " text += \"; \".join(row) + \"\\n\"\n", + " finally:\n", + " conn.close()\n", + "\n", + " return text" + ], + "metadata": { + "id": "o5tfHsPVz0zh" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Let's first check that functions work on its own, without agent" + ], + "metadata": { + "id": "DQDQ-1sm6Duz" + } + }, + { + "cell_type": "code", + "source": [ + "tables = db_query(\"SELECT name FROM sqlite_master WHERE type='table';\")\n", + "print(\"Tables:\", tables)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ytXU4hSNzYu4", + "outputId": "9fcea9fe-6ec9-4440-a515-d2f6b0064005" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Tables: name\n", + "lifespan_change\n", + "gene_criteria\n", + "gene_hallmarks\n", + "longevity_associations\n", + "\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Making a naive sql agent\n", + "\n", + "Now we will create an agent, It will handle simple tasks." + ], + "metadata": { + "id": "qKe3GAnb6UPd" + } + }, + { + "cell_type": "markdown", + "source": [ + "First, let's install the just-agent library with pip and set up API keys for Groq and OpenAI" + ], + "metadata": { + "id": "mJ8gblYm6QOd" + } + }, + { + "cell_type": "code", + "source": [ + "!pip install just-agents" + ], + "metadata": { + "id": "f2V1eHN66eb9", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "1021509a-2b72-4bf3-ad1a-bbce621d0945", + "collapsed": true + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting just-agents\n", + " Downloading just_agents-0.2.5-py2.py3-none-any.whl.metadata (7.1 kB)\n", + "Collecting litellm>=1.51.0 (from just-agents)\n", + " Downloading litellm-1.52.6-py3-none-any.whl.metadata (32 kB)\n", + "Collecting numpydoc (from just-agents)\n", + " Downloading numpydoc-1.8.0-py3-none-any.whl.metadata (4.3 kB)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from just-agents) (2.32.3)\n", + "Requirement already satisfied: typer>=0.12.5 in /usr/local/lib/python3.10/dist-packages (from just-agents) (0.13.0)\n", + "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (3.10.10)\n", + "Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (8.1.7)\n", + "Requirement already satisfied: importlib-metadata>=6.8.0 in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (8.5.0)\n", + "Requirement already satisfied: jinja2<4.0.0,>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (3.1.4)\n", + "Requirement already satisfied: jsonschema<5.0.0,>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (4.23.0)\n", + "Requirement already satisfied: openai>=1.54.0 in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (1.54.3)\n", + "Requirement already satisfied: pydantic<3.0.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (2.9.2)\n", + "Collecting python-dotenv>=0.2.0 (from litellm>=1.51.0->just-agents)\n", + " Downloading python_dotenv-1.0.1-py3-none-any.whl.metadata (23 kB)\n", + "Collecting tiktoken>=0.7.0 (from litellm>=1.51.0->just-agents)\n", + " Downloading tiktoken-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)\n", + "Requirement already satisfied: tokenizers in /usr/local/lib/python3.10/dist-packages (from litellm>=1.51.0->just-agents) (0.20.3)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->just-agents) (3.4.0)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->just-agents) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->just-agents) (2.2.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->just-agents) (2024.8.30)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from typer>=0.12.5->just-agents) (4.12.2)\n", + "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer>=0.12.5->just-agents) (1.5.4)\n", + "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.10/dist-packages (from typer>=0.12.5->just-agents) (13.9.4)\n", + "Requirement already satisfied: sphinx>=6 in /usr/local/lib/python3.10/dist-packages (from numpydoc->just-agents) (8.1.3)\n", + "Requirement already satisfied: tabulate>=0.8.10 in /usr/local/lib/python3.10/dist-packages (from numpydoc->just-agents) (0.9.0)\n", + "Requirement already satisfied: tomli>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from numpydoc->just-agents) (2.0.2)\n", + "Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.10/dist-packages (from importlib-metadata>=6.8.0->litellm>=1.51.0->just-agents) (3.20.2)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2<4.0.0,>=3.1.2->litellm>=1.51.0->just-agents) (3.0.2)\n", + "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.22.0->litellm>=1.51.0->just-agents) (24.2.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.22.0->litellm>=1.51.0->just-agents) (2024.10.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.22.0->litellm>=1.51.0->just-agents) (0.35.1)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema<5.0.0,>=4.22.0->litellm>=1.51.0->just-agents) (0.21.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (3.7.1)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.27.2)\n", + "Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.0)\n", + "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (4.66.6)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (2.23.4)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer>=0.12.5->just-agents) (3.0.0)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=10.11.0->typer>=0.12.5->just-agents) (2.18.0)\n", + "Requirement already satisfied: sphinxcontrib-applehelp>=1.0.7 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.0.0)\n", + "Requirement already satisfied: sphinxcontrib-devhelp>=1.0.6 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.0.0)\n", + "Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.1.0)\n", + "Requirement already satisfied: sphinxcontrib-jsmath>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (1.0.1)\n", + "Requirement already satisfied: sphinxcontrib-qthelp>=1.0.6 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.0.0)\n", + "Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.9 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.0.0)\n", + "Requirement already satisfied: docutils<0.22,>=0.20 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (0.21.2)\n", + "Requirement already satisfied: snowballstemmer>=2.2 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.2.0)\n", + "Requirement already satisfied: babel>=2.13 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (2.16.0)\n", + "Requirement already satisfied: alabaster>=0.7.14 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (1.0.0)\n", + "Requirement already satisfied: imagesize>=1.3 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (1.4.1)\n", + "Requirement already satisfied: packaging>=23.0 in /usr/local/lib/python3.10/dist-packages (from sphinx>=6->numpydoc->just-agents) (24.2)\n", + "Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.10/dist-packages (from tiktoken>=0.7.0->litellm>=1.51.0->just-agents) (2024.9.11)\n", + "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (2.4.3)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (1.3.1)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (1.5.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (6.1.0)\n", + "Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (1.17.1)\n", + "Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->litellm>=1.51.0->just-agents) (4.0.3)\n", + "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /usr/local/lib/python3.10/dist-packages (from tokenizers->litellm>=1.51.0->just-agents) (0.26.2)\n", + "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5,>=3.5.0->openai>=1.54.0->litellm>=1.51.0->just-agents) (1.2.2)\n", + "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->openai>=1.54.0->litellm>=1.51.0->just-agents) (1.0.6)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai>=1.54.0->litellm>=1.51.0->just-agents) (0.14.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->litellm>=1.51.0->just-agents) (3.16.1)\n", + "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->litellm>=1.51.0->just-agents) (2024.10.0)\n", + "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers->litellm>=1.51.0->just-agents) (6.0.2)\n", + "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer>=0.12.5->just-agents) (0.1.2)\n", + "Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp->litellm>=1.51.0->just-agents) (0.2.0)\n", + "Downloading just_agents-0.2.5-py2.py3-none-any.whl (50 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.0/50.0 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading litellm-1.52.6-py3-none-any.whl (6.4 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.4/6.4 MB\u001b[0m \u001b[31m56.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading numpydoc-1.8.0-py3-none-any.whl (64 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m64.0/64.0 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hDownloading python_dotenv-1.0.1-py3-none-any.whl (19 kB)\n", + "Downloading tiktoken-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m55.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: python-dotenv, tiktoken, numpydoc, litellm, just-agents\n", + "Successfully installed just-agents-0.2.5 litellm-1.52.6 numpydoc-1.8.0 python-dotenv-1.0.1 tiktoken-0.8.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "import os\n", + "import getpass\n", + "\n", + "def get_api_keys():\n", + " \"\"\"Gets API keys from the user.\"\"\"\n", + "\n", + " print(\"Please enter your API keys:\")\n", + " groq_api_key = getpass.getpass(\"GROQ_API_KEY: \")\n", + " openai_api_key = getpass.getpass(\"OPENAI_API_KEY: \")\n", + "\n", + " # Set environment variables\n", + " os.environ[\"GROQ_API_KEY\"] = groq_api_key\n", + " os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n", + "\n", + " print(\"API keys set successfully.\")\n", + "\n", + "# Call the function to get API keys from the user\n", + "get_api_keys()\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ZWr1xcrh8XE_", + "outputId": "8d41ca14-0029-466b-868d-6eb80a88e082", + "collapsed": true + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Please enter your API keys:\n", + "GROQ_API_KEY: ··········\n", + "OPENAI_API_KEY: ··········\n", + "API keys set successfully.\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "The following code just allows for user to see all comands and text outputed in the interface- it is needed to see all that comes out if the output is large." + ], + "metadata": { + "id": "Mvsbn4V7nkPr" + } + }, + { + "cell_type": "code", + "source": [ + "from IPython.core.interactiveshell import InteractiveShell\n", + "InteractiveShell.ast_node_interactivity = \"all\"\n" + ], + "metadata": { + "id": "LCwo282bEAMb" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Then we will create a simple agent that will use the db_query function as a tool and will answer questions which involve the database" + ], + "metadata": { + "id": "ZMHmYMDG6kwq" + } + }, + { + "cell_type": "markdown", + "source": [ + "Let's ask the agent some simple questions" + ], + "metadata": { + "id": "5iPvx0eN6v1M" + } + }, + { + "cell_type": "code", + "source": [ + "import asyncio\n", + "import json\n", + "import pprint\n", + "import just_agents\n", + "from just_agents import llm_options\n", + "from just_agents.llm_session import LLMSession\n", + "\n", + "llm_options = just_agents.llm_options.OPENAI_GPT4oMINI\n", + "\n", + "\n", + "\n", + "prompt = \"What processes are improved in GHR knockout mice?\"\n", + "\n", + "session: LLMSession = LLMSession(\n", + " llm_options=just_agents.llm_options.OPENAI_GPT4oMINI,\n", + " tools=[db_query]\n", + ")\n", + "\n", + "\n", + "result = session.query(prompt)\n", + "\n", + "session.memory.add_on_message(lambda m: pprint.pprint(m))\n", + "result = session.query(prompt)\n", + "\n", + "print(\"RESULT+++++++++++++++++++++++++++++++++++++++++++++++\")\n", + "print(result)" + ], + "metadata": { + "id": "aiC6qF026yFA", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "5dfb1933-d6d3-4c26-e3df-9393cedfe831", + "collapsed": true + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'content': 'What processes are improved in GHR knockout mice?', 'role': 'user'}\n", + "{'content': 'In GHR (Growth Hormone Receptor) knockout mice, several '\n", + " 'physiological and metabolic processes have been observed to '\n", + " 'improve or change. Here are some key areas where improvements are '\n", + " 'noted:\\n'\n", + " '\\n'\n", + " '1. **Metabolic Health**: GHR knockout mice often exhibit enhanced '\n", + " 'insulin sensitivity and improved glucose metabolism, which can '\n", + " 'lead to a lower risk of obesity and type 2 diabetes.\\n'\n", + " '\\n'\n", + " '2. **Lifespan Extension**: These mice tend to have a longer '\n", + " 'lifespan compared to their wild-type counterparts. This is '\n", + " 'associated with reduced growth hormone signaling, which is linked '\n", + " 'to various longevity pathways.\\n'\n", + " '\\n'\n", + " '3. **Reduced Inflammation**: GHR knockout mice may show lower '\n", + " 'levels of chronic inflammation, which is beneficial as chronic '\n", + " 'inflammation is associated with many age-related diseases.\\n'\n", + " '\\n'\n", + " '4. **Muscle Function and Strength**: There is evidence that GHR '\n", + " 'knockout mice may have improved muscle function and endurance, '\n", + " 'potentially due to changes in muscle fiber composition and '\n", + " 'reduced muscle wasting.\\n'\n", + " '\\n'\n", + " '5. **Cognitive Function**: Some studies suggest that GHR knockout '\n", + " 'can lead to enhanced cognitive functions and neuroprotection, '\n", + " 'possibly due to reduced oxidative stress and inflammation in the '\n", + " 'brain.\\n'\n", + " '\\n'\n", + " '6. **Bone Density**: GHR knockout mice may exhibit changes in '\n", + " 'bone density, often showing increased bone mass and improved bone '\n", + " 'quality.\\n'\n", + " '\\n'\n", + " 'These improvements are largely attributed to the reduced '\n", + " 'signaling through the growth hormone pathway, which affects '\n", + " 'various metabolic and physiological processes. If you have '\n", + " 'specific areas of interest or need more detailed information, '\n", + " 'feel free to ask!',\n", + " 'role': 'assistant'}\n", + "RESULT+++++++++++++++++++++++++++++++++++++++++++++++\n", + "In GHR (Growth Hormone Receptor) knockout mice, several physiological and metabolic processes have been observed to improve or change. Here are some key areas where improvements are noted:\n", + "\n", + "1. **Metabolic Health**: GHR knockout mice often exhibit enhanced insulin sensitivity and improved glucose metabolism, which can lead to a lower risk of obesity and type 2 diabetes.\n", + "\n", + "2. **Lifespan Extension**: These mice tend to have a longer lifespan compared to their wild-type counterparts. This is associated with reduced growth hormone signaling, which is linked to various longevity pathways.\n", + "\n", + "3. **Reduced Inflammation**: GHR knockout mice may show lower levels of chronic inflammation, which is beneficial as chronic inflammation is associated with many age-related diseases.\n", + "\n", + "4. **Muscle Function and Strength**: There is evidence that GHR knockout mice may have improved muscle function and endurance, potentially due to changes in muscle fiber composition and reduced muscle wasting.\n", + "\n", + "5. **Cognitive Function**: Some studies suggest that GHR knockout can lead to enhanced cognitive functions and neuroprotection, possibly due to reduced oxidative stress and inflammation in the brain.\n", + "\n", + "6. **Bone Density**: GHR knockout mice may exhibit changes in bone density, often showing increased bone mass and improved bone quality.\n", + "\n", + "These improvements are largely attributed to the reduced signaling through the growth hormone pathway, which affects various metabolic and physiological processes. If you have specific areas of interest or need more detailed information, feel free to ask!\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "It got this question right, but what if we want to know \"Interventions on which genes extended mice lifespan most of all?\"" + ], + "metadata": { + "id": "PVcJsmb-61gQ" + } + }, + { + "cell_type": "code", + "source": [ + "llm_options = just_agents.llm_options.OPENAI_GPT4o\n", + "\n", + "\n", + "prompt = \"Interventions on which genes extended mice lifespan most of all?\"\n", + "\n", + "session: LLMSession = LLMSession(\n", + " llm_options=just_agents.llm_options.OPENAI_GPT4o,\n", + " tools=[db_query]\n", + ")\n", + "\n", + "\n", + "result = session.query(prompt)\n", + "\n", + "session.memory.add_on_message(lambda m: pprint.pprint(m))\n", + "result = session.query(prompt)\n", + "\n", + "print(\"RESULT+++++++++++++++++++++++++++++++++++++++++++++++\")\n", + "print(result)" + ], + "metadata": { + "id": "M3fDkAfu650w", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "9d5bc5b0-6e22-46a6-b0a4-44ad37317a73", + "collapsed": true + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'content': 'Interventions on which genes extended mice lifespan most of all?',\n", + " 'role': 'user'}\n", + "{'role': 'assistant',\n", + " 'tool_calls': [{'function': {'arguments': '{\"sql\":\"SELECT gene_symbol, '\n", + " 'lifespan_extension_percentage FROM '\n", + " 'gene_interventions ORDER BY '\n", + " 'lifespan_extension_percentage DESC '\n", + " 'LIMIT 5;\"}',\n", + " 'name': 'db_query'},\n", + " 'id': 'call_TQeDlEiPMIcgiPNpDR55t4lk',\n", + " 'type': 'function'}]}\n", + "{'content': 'no such table: gene_interventions',\n", + " 'name': 'db_query',\n", + " 'role': 'tool',\n", + " 'tool_call_id': 'call_TQeDlEiPMIcgiPNpDR55t4lk'}\n", + "{'content': 'I am unable to access the database table containing information '\n", + " 'on gene interventions and lifespan extension in mice. If you have '\n", + " 'access to specific data or another source, I can help interpret '\n", + " 'it. Otherwise, feel free to ask about other topics or questions!',\n", + " 'role': 'assistant'}\n", + "RESULT+++++++++++++++++++++++++++++++++++++++++++++++\n", + "I am unable to access the database table containing information on gene interventions and lifespan extension in mice. If you have access to specific data or another source, I can help interpret it. Otherwise, feel free to ask about other topics or questions!\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "As you see the SQL returned zero results although we know that the data exist by browsing https://open-genes.com/ and/or sqlite file. Let's modify the system prompt to get it right\n", + "\n", + "In this case it was the simple change from model OPENAI-GPT4oMINI to OPENAI-GPT4o.\n", + "\n", + "But how to make it better? simply call the LLMSession with a prompt." + ], + "metadata": { + "id": "8v7IpNnU6-KR" + } + }, + { + "cell_type": "code", + "source": [ + "!wget https://github.com/longevity-genie/longevity_gpts/blob/main/prompts/open_genes.txt -O open_genes.txt" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "collapsed": true, + "id": "qAL9oC97qpNl", + "outputId": "9f52e5be-863b-45fc-e2bc-a67491c4a668" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "--2024-11-14 16:35:59-- https://github.com/longevity-genie/longevity_gpts/blob/main/prompts/open_genes.txt\n", + "Resolving github.com (github.com)... 140.82.112.3\n", + "Connecting to github.com (github.com)|140.82.112.3|:443... connected.\n", + "HTTP request sent, awaiting response... 200 OK\n", + "Length: unspecified [text/html]\n", + "Saving to: ‘open_genes.txt’\n", + "\n", + "open_genes.txt [ <=> ] 744.54K --.-KB/s in 0.1s \n", + "\n", + "2024-11-14 16:36:00 (5.82 MB/s) - ‘open_genes.txt’ saved [762412]\n", + "\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "llm_options = just_agents.llm_options.OPENAI_GPT4o\n", + "\n", + "\n", + "prompt = \"Interventions on which genes extended mice lifespan most of all? Search all the relevant tables in the open-genes sqlite and only for mouse\"\n", + "\n", + "session: LLMSession = LLMSession(\n", + " llm_options=just_agents.llm_options.OPENAI_GPT4o,\n", + " system_prompt='open_genes.txt',\n", + " tools=[db_query]\n", + ")\n", + "\n", + "\n", + "result = session.query(prompt)\n", + "\n", + "session.memory.add_on_message(lambda m: pprint.pprint(m))\n", + "result = session.query(prompt)\n", + "\n", + "print(\"RESULT+++++++++++++++++++++++++++++++++++++++++++++++\")\n", + "print(result)" + ], + "metadata": { + "id": "P5YcWoig7H6j", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "52996f93-2d8a-475e-8400-02be186f76d0" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'content': 'Interventions on which genes extended mice lifespan most of all? '\n", + " 'Search all the relevant tables in the open-genes sqlite and only '\n", + " 'for mouse',\n", + " 'role': 'user'}\n", + "{'role': 'assistant',\n", + " 'tool_calls': [{'function': {'arguments': '{\"sql\":\"SELECT HGNC, '\n", + " 'intervention_improves, '\n", + " 'lifespan_percent_change_max FROM '\n", + " 'lifespan_change WHERE '\n", + " \"model_organism = 'mouse' ORDER BY \"\n", + " 'lifespan_percent_change_max DESC '\n", + " 'LIMIT 5;\"}',\n", + " 'name': 'db_query'},\n", + " 'id': 'call_CtjNg4UK9gQeKrAiPpw8z3t5',\n", + " 'type': 'function'}]}\n", + "{'content': 'HGNC; intervention_improves; lifespan_percent_change_max\\n'\n", + " 'PROP1; insulin sensitivity,INS/IGFR pathway; 60.0\\n'\n", + " 'PROP1; None; 46.0\\n'\n", + " 'PIK3CA; None; 45.0\\n'\n", + " 'PROP1; glucose metabolism,INS/IGFR pathway; 44.7\\n'\n", + " 'PROP1; None; 44.0\\n',\n", + " 'name': 'db_query',\n", + " 'role': 'tool',\n", + " 'tool_call_id': 'call_CtjNg4UK9gQeKrAiPpw8z3t5'}\n", + "{'content': 'The interventions on genes that extended the lifespan of mice the '\n", + " 'most are as follows:\\n'\n", + " '\\n'\n", + " '1. **PROP1**: Improved insulin sensitivity and INS/IGFR pathway, '\n", + " 'resulting in a 60% lifespan extension.\\n'\n", + " '2. **PROP1**: No specific improvement noted, resulting in a 46% '\n", + " 'lifespan extension.\\n'\n", + " '3. **PIK3CA**: No specific improvement noted, resulting in a 45% '\n", + " 'lifespan extension.\\n'\n", + " '4. **PROP1**: Improved glucose metabolism and INS/IGFR pathway, '\n", + " 'resulting in a 44.7% lifespan extension.\\n'\n", + " '5. **PROP1**: No specific improvement noted, resulting in a 44% '\n", + " 'lifespan extension.',\n", + " 'role': 'assistant'}\n", + "RESULT+++++++++++++++++++++++++++++++++++++++++++++++\n", + "The interventions on genes that extended the lifespan of mice the most are as follows:\n", + "\n", + "1. **PROP1**: Improved insulin sensitivity and INS/IGFR pathway, resulting in a 60% lifespan extension.\n", + "2. **PROP1**: No specific improvement noted, resulting in a 46% lifespan extension.\n", + "3. **PIK3CA**: No specific improvement noted, resulting in a 45% lifespan extension.\n", + "4. **PROP1**: Improved glucose metabolism and INS/IGFR pathway, resulting in a 44.7% lifespan extension.\n", + "5. **PROP1**: No specific improvement noted, resulting in a 44% lifespan extension.\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "Now to check it let's call the same code but with model OPENAIgpt4omini" + ], + "metadata": { + "id": "UdHp2OAk7MTg" + } + }, + { + "cell_type": "code", + "source": [ + "llm_options = just_agents.llm_options.OPENAI_GPT4oMINI\n", + "\n", + "\n", + "prompt = \"Interventions on which genes extended mice lifespan most of all? Search all the relevant tables in the open-genes sqlite and only for mouse\"\n", + "\n", + "\n", + "session: LLMSession = LLMSession(\n", + " llm_options=just_agents.llm_options.OPENAI_GPT4oMINI,\n", + " system_prompt='open_genes.txt',\n", + " tools=[db_query]\n", + ")\n", + "\n", + "\n", + "result = session.query(prompt)\n", + "\n", + "session.memory.add_on_message(lambda m: pprint.pprint(m))\n", + "result = session.query(prompt)\n", + "\n", + "print(\"RESULT+++++++++++++++++++++++++++++++++++++++++++++++\")\n", + "print(result)" + ], + "metadata": { + "id": "bdd1wW3_7OYw", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "dda48f04-4e14-49ed-ce6b-9c7c2460cd00" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'content': 'Interventions on which genes extended mice lifespan most of all? '\n", + " 'Search all the relevant tables in the open-genes sqlite and only '\n", + " 'for mouse',\n", + " 'role': 'user'}\n", + "{'role': 'assistant',\n", + " 'tool_calls': [{'function': {'arguments': '{\"sql\": \"SELECT HGNC, '\n", + " 'effect_on_lifespan, '\n", + " 'control_lifespan_mean, '\n", + " 'experiment_lifespan_mean, '\n", + " 'lifespan_percent_change_mean FROM '\n", + " 'lifespan_change WHERE '\n", + " \"model_organism = 'mouse' AND \"\n", + " 'effect_on_lifespan LIKE '\n", + " \"'%increases lifespan%' ORDER BY \"\n", + " 'lifespan_percent_change_mean DESC '\n", + " 'LIMIT 10;\"}',\n", + " 'name': 'db_query'},\n", + " 'id': 'call_cfgC57TBJ6QiQI83tni7Vwwo',\n", + " 'type': 'function'},\n", + " {'function': {'arguments': '{\"sql\": \"SELECT gene_name, '\n", + " 'intervention_type, '\n", + " 'lifespan_extension FROM '\n", + " 'longevity_associations WHERE '\n", + " 'species = \\'mouse\\';\"}',\n", + " 'name': 'db_query'},\n", + " 'id': 'call_YafB9vMvzOtS298KhWBostUp',\n", + " 'type': 'function'}]}\n", + "{'content': 'HGNC; effect_on_lifespan; control_lifespan_mean; '\n", + " 'experiment_lifespan_mean; lifespan_percent_change_mean\\n'\n", + " 'GHR; increases lifespan; 700.7; 1179.0; 68.2\\n'\n", + " 'PROP1; increases lifespan; 718.0; 1206.0; 68.0\\n'\n", + " 'GHR; increases lifespan; 629.0; 975.0; 55.0\\n'\n", + " 'VEGFA; increases lifespan; 628.37; 953.27; 51.7\\n'\n", + " 'PROP1; increases lifespan; 723.0; 1076.0; 49.0\\n'\n", + " 'POU1F1; increases lifespan; 571.0; 844.0; 48.0\\n'\n", + " 'POU1F1; increases lifespan; 28.6; 39.4; 42.0\\n'\n", + " 'POU1F1; increases lifespan; 811.0; 1148.0; 42.0\\n'\n", + " 'VEGFA; increases lifespan; 671.0; 952.0; 41.9\\n'\n", + " 'UCP1; increases lifespan; 523.0; 736.0; 40.7\\n',\n", + " 'name': 'db_query',\n", + " 'role': 'tool',\n", + " 'tool_call_id': 'call_cfgC57TBJ6QiQI83tni7Vwwo'}\n", + "{'content': 'no such column: gene_name',\n", + " 'name': 'db_query',\n", + " 'role': 'tool',\n", + " 'tool_call_id': 'call_YafB9vMvzOtS298KhWBostUp'}\n", + "{'content': 'Based on the data retrieved from the `lifespan_change` table, '\n", + " 'here are the genes associated with interventions that extended '\n", + " 'the lifespan of mice:\\n'\n", + " '\\n'\n", + " '### Genes and Their Lifespan Extension Effects\\n'\n", + " '\\n'\n", + " '1. **GHR**\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 700.7 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 1179.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 68.2%\\n'\n", + " '\\n'\n", + " '2. **PROP1**\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 718.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 1206.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 68.0%\\n'\n", + " '\\n'\n", + " '3. **GHR** (another entry)\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 629.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 975.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 55.0%\\n'\n", + " '\\n'\n", + " '4. **VEGFA**\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 628.37 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 953.27 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 51.7%\\n'\n", + " '\\n'\n", + " '5. **PROP1** (another entry)\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 723.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 1076.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 49.0%\\n'\n", + " '\\n'\n", + " '6. **POU1F1**\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 571.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 844.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 48.0%\\n'\n", + " '\\n'\n", + " '7. **POU1F1** (another entry)\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 28.6 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 39.4 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 42.0%\\n'\n", + " '\\n'\n", + " '8. **POU1F1** (another entry)\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 811.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 1148.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 42.0%\\n'\n", + " '\\n'\n", + " '9. **VEGFA** (another entry)\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 671.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 952.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 41.9%\\n'\n", + " '\\n'\n", + " '10. **UCP1**\\n'\n", + " ' - **Effect on Lifespan**: Increases lifespan\\n'\n", + " ' - **Control Lifespan Mean**: 523.0 days\\n'\n", + " ' - **Experiment Lifespan Mean**: 736.0 days\\n'\n", + " ' - **Lifespan Percent Change Mean**: 40.7%\\n'\n", + " '\\n'\n", + " '### Summary\\n'\n", + " 'The genes **GHR** and **PROP1** show the most significant '\n", + " 'lifespan extensions in mice, with percent changes of 68.2% and '\n", + " '68.0%, respectively. Other notable genes include **VEGFA** and '\n", + " '**POU1F1**, which also contribute to lifespan increases.\\n'\n", + " '\\n'\n", + " 'If you need further details or specific analyses, feel free to '\n", + " 'ask!',\n", + " 'role': 'assistant'}\n", + "RESULT+++++++++++++++++++++++++++++++++++++++++++++++\n", + "Based on the data retrieved from the `lifespan_change` table, here are the genes associated with interventions that extended the lifespan of mice:\n", + "\n", + "### Genes and Their Lifespan Extension Effects\n", + "\n", + "1. **GHR**\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 700.7 days\n", + " - **Experiment Lifespan Mean**: 1179.0 days\n", + " - **Lifespan Percent Change Mean**: 68.2%\n", + "\n", + "2. **PROP1**\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 718.0 days\n", + " - **Experiment Lifespan Mean**: 1206.0 days\n", + " - **Lifespan Percent Change Mean**: 68.0%\n", + "\n", + "3. **GHR** (another entry)\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 629.0 days\n", + " - **Experiment Lifespan Mean**: 975.0 days\n", + " - **Lifespan Percent Change Mean**: 55.0%\n", + "\n", + "4. **VEGFA**\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 628.37 days\n", + " - **Experiment Lifespan Mean**: 953.27 days\n", + " - **Lifespan Percent Change Mean**: 51.7%\n", + "\n", + "5. **PROP1** (another entry)\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 723.0 days\n", + " - **Experiment Lifespan Mean**: 1076.0 days\n", + " - **Lifespan Percent Change Mean**: 49.0%\n", + "\n", + "6. **POU1F1**\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 571.0 days\n", + " - **Experiment Lifespan Mean**: 844.0 days\n", + " - **Lifespan Percent Change Mean**: 48.0%\n", + "\n", + "7. **POU1F1** (another entry)\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 28.6 days\n", + " - **Experiment Lifespan Mean**: 39.4 days\n", + " - **Lifespan Percent Change Mean**: 42.0%\n", + "\n", + "8. **POU1F1** (another entry)\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 811.0 days\n", + " - **Experiment Lifespan Mean**: 1148.0 days\n", + " - **Lifespan Percent Change Mean**: 42.0%\n", + "\n", + "9. **VEGFA** (another entry)\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 671.0 days\n", + " - **Experiment Lifespan Mean**: 952.0 days\n", + " - **Lifespan Percent Change Mean**: 41.9%\n", + "\n", + "10. **UCP1**\n", + " - **Effect on Lifespan**: Increases lifespan\n", + " - **Control Lifespan Mean**: 523.0 days\n", + " - **Experiment Lifespan Mean**: 736.0 days\n", + " - **Lifespan Percent Change Mean**: 40.7%\n", + "\n", + "### Summary\n", + "The genes **GHR** and **PROP1** show the most significant lifespan extensions in mice, with percent changes of 68.2% and 68.0%, respectively. Other notable genes include **VEGFA** and **POU1F1**, which also contribute to lifespan increases.\n", + "\n", + "If you need further details or specific analyses, feel free to ask!\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "This shows that even with careful arragement prompts can still fail. It is important to check the results and stability of results before anything else.\n", + "\n", + "Here are some more questions to be tested\n", + "\n", + "1. What genes need to be downregulated in worms to extend their lifespan?\n", + "2. What processes are improved in GHR knockout mice?\n", + "3. Which genetic intervention led to the greatest increase in lifespan in flies?\n", + "4. To what extent did the lifespan increase in mice overexpressing VEGFA?\n", + "5. Are there any liver-specific interventions that increase lifespan in mice?\n", + "6. Which gene-longevity association is confirmed by the greatest number of studies?\n", + "7. What polymorphisms in FOXO3 are associated with human longevity?\n", + "8. In which ethnic groups was the association of the APOE gene with longevity shown?\n", + "9. Is the INS gene polymorphism associated with longevity?\n", + "10. What genes are associated with transcriptional alterations?\n", + "11. Which hallmarks are associated with the KL gene?\n", + "12. What genes change their expression with aging in humans?\n", + "13. How many genes are associated with longevity in humans?\n", + "14. What types of studies have been conducted on the IGF1R gene?\n", + "15. What evidence of the link between PTEN and aging do you know?\n", + "16. What genes are associated with both longevity and altered expression in aged humans?\n", + "17. Is the expression of the ACE2 gene altered with aging in humans?\n", + "18. Interventions on which genes extended mice lifespan most of all?\n", + "19. Which knockdowns were most lifespan extending on model animals?" + ], + "metadata": { + "id": "zMzimFHt7Qgl" + } + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "1anUtpmM7S_-" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file