{"id":13577228,"url":"https://github.com/rgbkrk/genai","last_synced_at":"2025-04-05T20:06:11.101Z","repository":{"id":143367416,"uuid":"512204900","full_name":"rgbkrk/genai","owner":"rgbkrk","description":"What if GPT could help you notebook?","archived":false,"fork":false,"pushed_at":"2024-01-29T23:48:09.000Z","size":384,"stargazers_count":351,"open_issues_count":8,"forks_count":39,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-29T19:03:04.156Z","etag":null,"topics":["exceptions","gpt","gpt-35-turbo","interactive-computing","ipython","jupyter","openai","traceback"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgbkrk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-09T14:22:09.000Z","updated_at":"2025-01-17T11:05:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"6dcdd547-4676-4650-b78b-491b2ec8c03b","html_url":"https://github.com/rgbkrk/genai","commit_stats":null,"previous_names":["rgbkrk/genai","noteable-io/genai"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgbkrk%2Fgenai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgbkrk%2Fgenai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgbkrk%2Fgenai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgbkrk%2Fgenai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgbkrk","download_url":"https://codeload.github.com/rgbkrk/genai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393568,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exceptions","gpt","gpt-35-turbo","interactive-computing","ipython","jupyter","openai","traceback"],"created_at":"2024-08-01T15:01:19.513Z","updated_at":"2025-04-05T20:06:11.078Z","avatar_url":"https://github.com/rgbkrk.png","language":"Python","readme":"[Install](#installation) | [License](./LICENSE) | [Code of Conduct](./CODE_OF_CONDUCT.md) | [Contributing](./CONTRIBUTING.md)\n\n# GenAI: generative AI tooling for IPython\n\n🦾 Get GPT help with code, SQL queries, DataFrames, Exceptions and more in IPython.\n\n🌍 Supports all Jupyter environments, including IPython, JupyterLab, Jupyter Notebook, and Noteable.\n\nTL;DR Get started now\n\n```\n%pip install genai\n%load_ext genai\n```\n\n## Genai In Action\n\n![Genai making a suggestion followed by running suggested code](https://user-images.githubusercontent.com/836375/225177905-17cfb526-60f8-486d-b468-60a6a01db02e.gif)\n\n- [Blog Post](https://noteable.io/blog/introducing-genai/)\n- [Example Notebook](https://app.noteable.io/f/1605d16d-f5d3-4099-8fec-2ca727075b3b/Introducing-Genai.ipynb)\n\n\u003c!-- --8\u003c-- [start:intro] --\u003e\n\n## Introduction\n\nWe've taken the context from IPython, mixed it with OpenAI's Large Language Models, and are bringing you a more informed notebook experience that works in all Jupyter environments, including IPython, JupyterLab, Jupyter Notebook, and Noteable. 🦾🌏\n\n\u003c!-- --8\u003c-- [end:intro] --\u003e\n\n\u003c!-- --8\u003c-- [start:requirements] --\u003e\n\n## Requirements\n\nPython 3.8+\n\n\u003c!-- --8\u003c-- [end:requirements] --\u003e\n\n\u003c!-- --8\u003c-- [start:install] --\u003e\n\n## Installation\n\n### Poetry\n\n```shell\npoetry add genai\n```\n\n### Pip\n\n```shell\npip install genai\n```\n\n\u003c!-- --8\u003c-- [end:install] --\u003e\n\n\u003c!-- --8\u003c-- [start:start] --\u003e\n\n## Loading the IPython extension\n\nMake sure to set the `OPENAI_API_KEY` environment variable first before using it in IPython or your [preferred notebook platform of choice](https://noteable.io/).\n\n```\n%load_ext genai\n```\n\n## Features\n\n- `%%assist` magic command to generate code from natural language\n- Custom exception suggestions\n\n### Custom Exception Suggestions\n\n```python\nIn [1]: %load_ext genai\n\nIn [2]: import pandas as pd\n\nIn [3]: df = pd.DataFrame(dict(col1=['a', 'b', 'c']), index=['first', 'second', 'third'])\n\nIn [4]: df.sort_values()\n---------------------------------------------------------------------------\nTypeError                                 Traceback (most recent call last)\nCell In[4], line 1\n----\u003e 1 df.sort_values()\n\nFile ~/.pyenv/versions/3.9.9/lib/python3.9/site-packages/pandas/util/_decorators.py:331, in deprecate_nonkeyword_arguments.\u003clocals\u003e.decorate.\u003clocals\u003e.wrapper(*args, **kwargs)\n    325 if len(args) \u003e num_allow_args:\n    326     warnings.warn(\n    327         msg.format(arguments=_format_argument_list(allow_args)),\n    328         FutureWarning,\n    329         stacklevel=find_stack_level(),\n    330     )\n--\u003e 331 return func(*args, **kwargs)\n\nTypeError: sort_values() missing 1 required positional argument: 'by'\n```\n\n#### 💡 Suggestion\n\nThe error message is indicating that the `sort_values()` method of a pandas dataframe is missing a required positional argument.\n\nThe `sort_values()` method requires you to pass a column name or list of column names as the `by` argument. This is used to determine how the sorting will be performed.\n\nHere's an example:\n\n```python\nimport pandas as pd\n\ndf = pd.DataFrame({\n    'Name': ['Alice', 'Bob', 'Carol', 'David', 'Eva'],\n    'Age': [32, 24, 28, 35, 29],\n    'Salary': [60000, 40000, 35000, 80000, 45000]\n})\n\n# sort by Age column:\ndf_sorted = df.sort_values(by='Age')\nprint(df_sorted)\n```\n\nIn this example, the `by` argument is set to `'Age'`, which sorts the dataframe by age in ascending order. Note that you can also pass a list of column names if you want to sort by multiple columns.\n\n## Example\n\n````python\nIn [1]: %load_ext genai\n\nIn [2]: %%assist\n   ...:\n   ...: Can you explain this query to me so I can be sure we're doing the right things?\n   ...:\n   ...: ```sql\n   ...: SELECT\n   ...:   COUNT(*) AS num_downloads,\n   ...:   DATE_TRUNC(DATE(timestamp), DAY) AS day\n   ...: FROM `bigquery-public-data.pypi.file_downloads`\n   ...: WHERE\n   ...:   file.project = 'genai'\n   ...:   -- Only query the last 6 months of history\n   ...:   AND DATE(timestamp)\n   ...:     BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH)\n   ...:     AND CURRENT_DATE()\n   ...: GROUP BY day\n   ...: ORDER BY day DESC\n````\n\n```markdown\n\"This is a SQL query that counts the number of downloads for the 'genai' project on the Python Package Index (PyPI) over the last 6 months, grouped by day. The query selects the count and the date, truncating the date to the day level so that it's easier to read.\n\nHere is a breakdown of each part of the query:\n\n- `SELECT COUNT(*) AS num_downloads, DATE_TRUNC(DATE(timestamp), DAY) AS day`: This selects the count of the number of rows matched by the query as `num_downloads`, and the date truncated to the day level as `day`.\n- `FROM `bigquery-public-data.pypi.file_downloads``: This specifies the table to query from.\n- `WHERE file.project = 'genai'`: This filters the rows by only including downloads for the 'genai' project.\n- `AND DATE(timestamp) BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), MONTH) AND CURRENT_DATE()`: This filters the rows by only including downloads from the last 6 months. The `DATE_SUB` function subtracts 6 months from the current date (`CURRENT_DATE()`), `DATE_TRUNC` truncates the result to be the start of the month and `DATE` converts the timestamp column to a date so the `BETWEEN` condition can filter rows between the start of 6 months ago and \"today.\"\n- `GROUP BY day`: This groups the rows by day so that the counts are aggregated by date.\n- `ORDER BY day DESC`: This orders the rows so that the most recent date appears first in the result.\"\n```\n\n\u003c!-- --8\u003c-- [end:start] --\u003e\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgbkrk%2Fgenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgbkrk%2Fgenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgbkrk%2Fgenai/lists"}