From 87510b02850325a4063e136c2777dd97740dd23e Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:23:40 +0530 Subject: [PATCH 01/52] Create .readthedocs.yaml --- .readthedocs.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 000000000..9138a7fe5 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,13 @@ +version: "2" + +build: + os: "ubuntu-22.04" + tools: + python: "3.10" + +python: + install: + - requirements: docs/requirements.txt + +sphinx: + configuration: docs/source/conf.py From 9fb4f0880714fd2666f330827f8dfa5c6ddd7098 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:36:41 +0530 Subject: [PATCH 02/52] Update .readthedocs.yaml --- .readthedocs.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9138a7fe5..f415f9918 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,13 +1,20 @@ version: "2" build: - os: "ubuntu-22.04" + os: "ubuntu-24.04" tools: - python: "3.10" + python: + - "3.12" + - "3.11" + - "3.10" + - "3.9" +env: + GEMINI_API_KEY: ${GEMINI_API_KEY} + python: install: - - requirements: docs/requirements.txt + - . sphinx: - configuration: docs/source/conf.py + configuration: docs/conf.py From b88e7dd500e9d463cf78d0c70e4b1d8506e3fccb Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:11:22 +0530 Subject: [PATCH 03/52] Update .readthedocs.yaml --- .readthedocs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f415f9918..7b4f2da3f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -16,5 +16,5 @@ python: install: - . -sphinx: - configuration: docs/conf.py +# sphinx: +# configuration: docs/conf.py From d21c16d7b9fb6e96a69d11d814055a8df40c482d Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:15:40 +0530 Subject: [PATCH 04/52] Update .readthedocs.yaml --- .readthedocs.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7b4f2da3f..c8895005c 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,11 +3,10 @@ version: "2" build: os: "ubuntu-24.04" tools: - python: - - "3.12" - - "3.11" - - "3.10" - - "3.9" + python: "3.12" + python: "3.11" + python: "3.10" + python: "3.9" env: GEMINI_API_KEY: ${GEMINI_API_KEY} From 6abddcc1adfe4e395757348fcead88b42320d0d5 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:19:24 +0530 Subject: [PATCH 05/52] Update .readthedocs.yaml --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index c8895005c..6eef92b4d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,7 +13,7 @@ env: python: install: - - . + - path: . # sphinx: # configuration: docs/conf.py From c3d3d649f2eb23492107ed282d5d6115eea540c8 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma <41509646+vi-shruti@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:20:15 +0530 Subject: [PATCH 06/52] Update .readthedocs.yaml --- .readthedocs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 6eef92b4d..a12324072 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,8 +8,8 @@ build: python: "3.10" python: "3.9" -env: - GEMINI_API_KEY: ${GEMINI_API_KEY} +# env: +# GEMINI_API_KEY: ${GEMINI_API_KEY} python: install: From 11b0eb77596e27b5bf721f6de16acd38dbb72dfb Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Mon, 28 Oct 2024 21:49:52 +0530 Subject: [PATCH 07/52] Sphinx Installed and quick-started Sphinx --- .readthedocs.yaml | 4 ++-- docs/Makefile | 20 ++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ docs/source/conf.py | 38 ++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 20 ++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a12324072..c363c3934 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -15,5 +15,5 @@ python: install: - path: . -# sphinx: -# configuration: docs/conf.py +sphinx: + configuration: docs/source/conf.py diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..d0c3cbf10 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..dc1312ab0 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 000000000..9c25457ad --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,38 @@ +import os +import sys + +from setup import release_status + +# Add the project root directory to sys.path +sys.path.insert(0, os.path.abspath('../..')) # Adjust this path as necessary + +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'google-generativeai' +copyright = '2024, Google LLC' +author = 'Google LLC' +release = release_status + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'myst_parser', # For Markdown support +] + +# templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +# html_static_path = ['_static'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 000000000..13a9fdde4 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. google-generativeai documentation master file, created by + sphinx-quickstart on Mon Oct 28 20:59:10 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to google-generativeai's documentation! +=============================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From 23cd0a986f2864517cab105c56a417766fc11f7f Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Mon, 28 Oct 2024 21:57:08 +0530 Subject: [PATCH 08/52] Update conf.py --- docs/source/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 9c25457ad..c77b852a3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,8 +1,6 @@ import os import sys -from setup import release_status - # Add the project root directory to sys.path sys.path.insert(0, os.path.abspath('../..')) # Adjust this path as necessary @@ -17,7 +15,7 @@ project = 'google-generativeai' copyright = '2024, Google LLC' author = 'Google LLC' -release = release_status +release = "0.2.2" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration From e8284e5372346b519f03e0ca4f34cdf9efaf6bc0 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Mon, 28 Oct 2024 22:00:00 +0530 Subject: [PATCH 09/52] Update conf.py --- docs/source/conf.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index c77b852a3..cb61d7fb9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,9 +20,7 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = [ - 'myst_parser', # For Markdown support -] +extensions = [] # templates_path = ['_templates'] exclude_patterns = [] @@ -34,3 +32,9 @@ html_theme = 'alabaster' # html_static_path = ['_static'] + +source_suffix = { + # '.rst': 'restructuredtext', + # '.txt': 'restructuredtext', + '.md': 'markdown', +} \ No newline at end of file From 3697a05543ceb4272a08a8481e3f413a475f89d6 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Mon, 28 Oct 2024 22:04:13 +0530 Subject: [PATCH 10/52] Update conf.py --- docs/source/conf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index cb61d7fb9..0e88b04ca 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,10 +20,10 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = [] +# extensions = [] # templates_path = ['_templates'] -exclude_patterns = [] +# exclude_patterns = [] @@ -34,7 +34,7 @@ # html_static_path = ['_static'] source_suffix = { - # '.rst': 'restructuredtext', + '.rst': 'restructuredtext', # '.txt': 'restructuredtext', '.md': 'markdown', } \ No newline at end of file From d01c5189c1bc62106a1656226d106efe401bbd12 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 14:36:30 +0530 Subject: [PATCH 11/52] Experimenting sphinx-external-toc A sphinx extension that allows the documentation site-map (a.k.a Table of Contents) to be defined external to the documentation files. --- docs/source/conf.py | 8 +++++++- docs/source/index.rst | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0e88b04ca..ee247f2b9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,9 +22,15 @@ # extensions = [] + # pip install furo + # html_theme = 'furo' # templates_path = ['_templates'] -# exclude_patterns = [] +# conda install myst-parser # "myst_parser" +exclude_patterns = ["sphinx_external_toc"] + +external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_exclude_missing = False # Optional; set to True to exclude missing files # -- Options for HTML output ------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 13a9fdde4..a938c2e1f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,3 +18,6 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` + +.. .. include:: ../README.md + .. :parser: myst_parser \ No newline at end of file From ba26b3f2900c8f09d44e00783213f1b458a29c88 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 14:41:23 +0530 Subject: [PATCH 12/52] Update conf.py --- docs/source/conf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ee247f2b9..b541e2ec1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,17 +20,17 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# extensions = [] +extensions = ["sphinx_external_toc"] +external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo # html_theme = 'furo' # templates_path = ['_templates'] # conda install myst-parser # "myst_parser" -exclude_patterns = ["sphinx_external_toc"] +# exclude_patterns = [] -external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file -external_toc_exclude_missing = False # Optional; set to True to exclude missing files # -- Options for HTML output ------------------------------------------------- From d89a1904a29ee20f01232769d4eebcd5394eb358 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 14:49:02 +0530 Subject: [PATCH 13/52] Update conf.py --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index b541e2ec1..8b611a29a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,5 +1,6 @@ import os import sys +import sphinx_external_toc # Add the project root directory to sys.path sys.path.insert(0, os.path.abspath('../..')) # Adjust this path as necessary From e458d8fd43283e48d99aecf1fbef949743aa90fe Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 14:54:46 +0530 Subject: [PATCH 14/52] Added requirements --- .readthedocs.yaml | 1 + docs/requirements.txt | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 docs/requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml index c363c3934..90aa55454 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -14,6 +14,7 @@ build: python: install: - path: . + - requirements: docs/requirements.txt sphinx: configuration: docs/source/conf.py diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..65d567369 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx_external_toc \ No newline at end of file From 3654008fcfbe2e34dce6fda635419e77486ac229 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 15:01:50 +0530 Subject: [PATCH 15/52] Updated path --- docs/requirements.txt | 1 + docs/source/conf.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 65d567369..0c472d321 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ +myst_parser sphinx sphinx_external_toc \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 8b611a29a..70192a043 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["sphinx_external_toc"] -external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_path = "/api/google/generativeai/_toc.yaml" # Path to your YAML file external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo From 710543ce865e870ee00bdb4977839a3243d62c03 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 15:03:45 +0530 Subject: [PATCH 16/52] Update conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 70192a043..a17135a6e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["sphinx_external_toc"] -external_toc_path = "/api/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_path = "docs/api/google/generativeai/_toc.yaml" # Path to your YAML file external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo From db3cc98e14fdd5d04c630597eba6bef2e920864a Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 15:06:43 +0530 Subject: [PATCH 17/52] Update conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index a17135a6e..905518121 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["sphinx_external_toc"] -external_toc_path = "docs/api/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_path = "docs/api/python/google/generativeai/_toc.yaml" # Path to your YAML file external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo From 3a7cfb22f03f279934af59c489c5c0215af91a80 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 15:15:13 +0530 Subject: [PATCH 18/52] Update conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 905518121..8b611a29a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["sphinx_external_toc"] -external_toc_path = "docs/api/python/google/generativeai/_toc.yaml" # Path to your YAML file +external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo From 9db223de65eab5caa1052066fccea38087ebe9ba Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Tue, 29 Oct 2024 15:56:52 +0530 Subject: [PATCH 19/52] Update conf.py --- docs/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8b611a29a..6aed58ef7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,8 +22,8 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = ["sphinx_external_toc"] -external_toc_path = "/api/python/google/generativeai/_toc.yaml" # Path to your YAML file -external_toc_exclude_missing = False # Optional; set to True to exclude missing files +external_toc_path = "docs/api/google/generativeai/_toc.yaml" # Path to your YAML file +# external_toc_exclude_missing = False # Optional; set to True to exclude missing files # pip install furo # html_theme = 'furo' From aaa72b117fd3a943115a7ecbd69384d182b41368 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:10:52 +0530 Subject: [PATCH 20/52] Github Actions Workflow --- .github/workflows/gh_pages_doc.yaml | 45 +++++++++ .readthedocs.yaml | 20 ---- docs/Makefile | 4 +- docs/conf.py | 43 +++++++++ docs/index.md | 138 ++++++++++++++++++++++++++++ docs/make.bat | 4 +- docs/requirements.txt | 3 - docs/source/conf.py | 47 ---------- docs/source/index.rst | 23 ----- 9 files changed, 230 insertions(+), 97 deletions(-) create mode 100644 .github/workflows/gh_pages_doc.yaml delete mode 100644 .readthedocs.yaml create mode 100644 docs/conf.py create mode 100644 docs/index.md delete mode 100644 docs/requirements.txt delete mode 100644 docs/source/conf.py delete mode 100644 docs/source/index.rst diff --git a/.github/workflows/gh_pages_doc.yaml b/.github/workflows/gh_pages_doc.yaml new file mode 100644 index 000000000..cac559e60 --- /dev/null +++ b/.github/workflows/gh_pages_doc.yaml @@ -0,0 +1,45 @@ +name: Deploy Sphinx documentation to Pages + +on: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + pip install sphinx myst-parser + + - name: Build the documentation + run: | + cd docs + make html + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "docs/_build/html" + + pages: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + permissions: + pages: write + id-token: write + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.readthedocs.yaml b/.readthedocs.yaml deleted file mode 100644 index 90aa55454..000000000 --- a/.readthedocs.yaml +++ /dev/null @@ -1,20 +0,0 @@ -version: "2" - -build: - os: "ubuntu-24.04" - tools: - python: "3.12" - python: "3.11" - python: "3.10" - python: "3.9" - -# env: -# GEMINI_API_KEY: ${GEMINI_API_KEY} - -python: - install: - - path: . - - requirements: docs/requirements.txt - -sphinx: - configuration: docs/source/conf.py diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf10..d4bb2cbb9 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000..5780e8147 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,43 @@ +project = 'Google Generative AI - Python' +copyright = '2024, Google LLC' +author = 'Google LLC' + +extensions = [ + 'sphinx.ext.coverage', + 'myst_parser', + "myst_nb", + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', + ] + +myst_url_schemes = ["http", "https", "mailto"] +myst_enable_extensions = [ + "colon_fence", + "deflist", + "fieldlist", + "html_image", + "linkify", + "replacements", + "smartquotes", + "strikethrough", + "tasklist", + "substitution" +] + +source_suffix = {'.md': 'markdown',} +master_doc = 'index' # Changed in version 2.0: Default is 'index' (previously 'contents'). + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +html_theme = 'alabaster' +html_static_path = ['_static'] + +def set_relative_links(app, docname, source): + source[0] = source[0].replace( + '../google/generativeai/', + '/api/google/generativeai/' + ) + +def setup(app): + app.connect('source-read', set_relative_links) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 000000000..23ee47866 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,138 @@ +description: Google AI Python SDK + +
+ + + + +
+ +# Module: google.generativeai + + + + + + + + + +Google AI Python SDK + + + +## Setup + +```posix-terminal +pip install google-generativeai +``` + +## GenerativeModel + +Use `genai.GenerativeModel` to access the API: + +``` +import google.generativeai as genai +import os + +genai.configure(api_key=os.environ['API_KEY']) + +model = genai.GenerativeModel(model_name='gemini-1.5-flash') +response = model.generate_content('Teach me about how an LLM works') + +print(response.text) +``` + +See the [python quickstart](https://ai.google.dev/tutorials/python_quickstart) for more details. + +## Modules + +[`protos`](../google/generativeai/protos.md) module: This module provides low level access to the ProtoBuffer "Message" classes used by the API. + +[`types`](../google/generativeai/types.md) module: A collection of type definitions used throughout the library. + +## Classes + +[`class ChatSession`](../google/generativeai/ChatSession.md): Contains an ongoing conversation with the model. + +[`class GenerationConfig`](../google/generativeai/types/GenerationConfig.md): A simple dataclass used to configure the generation parameters of GenerativeModel.generate_content. + +[`class GenerativeModel`](../google/generativeai/GenerativeModel.md): The `genai.GenerativeModel` class wraps default parameters for calls to GenerativeModel.generate_content, GenerativeModel.count_tokens, and GenerativeModel.start_chat. + +## Functions + +[`chat(...)`](../google/generativeai/chat.md): Calls the API to initiate a chat with a model using provided parameters + +[`chat_async(...)`](../google/generativeai/chat_async.md): Calls the API to initiate a chat with a model using provided parameters + +[`configure(...)`](../google/generativeai/configure.md): Captures default client configuration. + +[`count_message_tokens(...)`](../google/generativeai/count_message_tokens.md): Calls the API to calculate the number of tokens used in the prompt. + +[`count_text_tokens(...)`](../google/generativeai/count_text_tokens.md): Calls the API to count the number of tokens in the text prompt. + +[`create_tuned_model(...)`](../google/generativeai/create_tuned_model.md): Calls the API to initiate a tuning process that optimizes a model for specific data, returning an operation object to track and manage the tuning progress. + +[`delete_file(...)`](../google/generativeai/delete_file.md): Calls the API to permanently delete a specified file using a supported file service. + +[`delete_tuned_model(...)`](../google/generativeai/delete_tuned_model.md): Calls the API to delete a specified tuned model + +[`embed_content(...)`](../google/generativeai/embed_content.md): Calls the API to create embeddings for content passed in. + +[`embed_content_async(...)`](../google/generativeai/embed_content_async.md): Calls the API to create async embeddings for content passed in. + +[`generate_embeddings(...)`](../google/generativeai/generate_embeddings.md): Calls the API to create an embedding for the text passed in. + +[`generate_text(...)`](../google/generativeai/generate_text.md): Calls the API to generate text based on the provided prompt. + +[`get_base_model(...)`](../google/generativeai/get_base_model.md): Calls the API to fetch a base model by name. + +[`get_file(...)`](../google/generativeai/get_file.md): Calls the API to retrieve a specified file using a supported file service. + +[`get_model(...)`](../google/generativeai/get_model.md): Calls the API to fetch a model by name. + +[`get_operation(...)`](../google/generativeai/get_operation.md): Calls the API to get a specific operation + +[`get_tuned_model(...)`](../google/generativeai/get_tuned_model.md): Calls the API to fetch a tuned model by name. + +[`list_files(...)`](../google/generativeai/list_files.md): Calls the API to list files using a supported file service. + +[`list_models(...)`](../google/generativeai/list_models.md): Calls the API to list all available models. + +[`list_operations(...)`](../google/generativeai/list_operations.md): Calls the API to list all operations + +[`list_tuned_models(...)`](../google/generativeai/list_tuned_models.md): Calls the API to list all tuned models. + +[`update_tuned_model(...)`](../google/generativeai/update_tuned_model.md): Calls the API to push updates to a specified tuned model where only certain attributes are updatable. + +[`upload_file(...)`](../google/generativeai/upload_file.md): Calls the API to upload a file using a supported file service. + + + + + + + + + + + + + + + +
+__version__ + +`'0.7.2'` +
+annotations + +Instance of `__future__._Feature` +
+ diff --git a/docs/make.bat b/docs/make.bat index dc1312ab0..954237b9b 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -7,8 +7,8 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set SOURCEDIR=source -set BUILDDIR=build +set SOURCEDIR=. +set BUILDDIR=_build %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 0c472d321..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -myst_parser -sphinx -sphinx_external_toc \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py deleted file mode 100644 index 6aed58ef7..000000000 --- a/docs/source/conf.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import sys -import sphinx_external_toc - -# Add the project root directory to sys.path -sys.path.insert(0, os.path.abspath('../..')) # Adjust this path as necessary - -# Configuration file for the Sphinx documentation builder. -# -# For the full list of built-in configuration values, see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information - -project = 'google-generativeai' -copyright = '2024, Google LLC' -author = 'Google LLC' -release = "0.2.2" - -# -- General configuration --------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration - -extensions = ["sphinx_external_toc"] -external_toc_path = "docs/api/google/generativeai/_toc.yaml" # Path to your YAML file -# external_toc_exclude_missing = False # Optional; set to True to exclude missing files - - # pip install furo - # html_theme = 'furo' -# templates_path = ['_templates'] - -# conda install myst-parser # "myst_parser" -# exclude_patterns = [] - - - -# -- Options for HTML output ------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output - -html_theme = 'alabaster' -# html_static_path = ['_static'] - -source_suffix = { - '.rst': 'restructuredtext', - # '.txt': 'restructuredtext', - '.md': 'markdown', -} \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index a938c2e1f..000000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. google-generativeai documentation master file, created by - sphinx-quickstart on Mon Oct 28 20:59:10 2024. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to google-generativeai's documentation! -=============================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. .. include:: ../README.md - .. :parser: myst_parser \ No newline at end of file From b32360513413b6d83e06bb3883d5c68dc67750a3 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:16:36 +0530 Subject: [PATCH 21/52] Update gh_pages_doc.yaml --- .github/workflows/gh_pages_doc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh_pages_doc.yaml b/.github/workflows/gh_pages_doc.yaml index cac559e60..1b1b58166 100644 --- a/.github/workflows/gh_pages_doc.yaml +++ b/.github/workflows/gh_pages_doc.yaml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | - pip install sphinx myst-parser + pip install sphinx myst-parser myst_nb - name: Build the documentation run: | From de533e1541b30dc04764e7a8cc2c680ee15b9e02 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:23:40 +0530 Subject: [PATCH 22/52] Update conf.py --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 5780e8147..b81c0776e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,7 +5,6 @@ extensions = [ 'sphinx.ext.coverage', 'myst_parser', - "myst_nb", 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', ] From 790b9dae2208862027f0034e464a09dd9af03c6d Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:26:34 +0530 Subject: [PATCH 23/52] Update conf.py --- docs/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b81c0776e..bd08fb63f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,7 +15,6 @@ "deflist", "fieldlist", "html_image", - "linkify", "replacements", "smartquotes", "strikethrough", @@ -30,7 +29,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] html_theme = 'alabaster' -html_static_path = ['_static'] +# html_static_path = ['_static'] def set_relative_links(app, docname, source): source[0] = source[0].replace( From d267e5b778d01eabc7171cbea301e4e147bfde9a Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:45:49 +0530 Subject: [PATCH 24/52] Update conf.py --- docs/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index bd08fb63f..6680be40d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,5 +37,10 @@ def set_relative_links(app, docname, source): '/api/google/generativeai/' ) + source[0] = source[0].replace( + '/api/google/generativeai/GenerativeModel.md', + 'index.md' + ) + def setup(app): app.connect('source-read', set_relative_links) From a0dab2d4667db8f469119d33ec3615ef9c570092 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 11:56:30 +0530 Subject: [PATCH 25/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 6680be40d..808d8a606 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,7 +39,7 @@ def set_relative_links(app, docname, source): source[0] = source[0].replace( '/api/google/generativeai/GenerativeModel.md', - 'index.md' + '/index.md' ) def setup(app): From bda54f891c191d0475378a4cd42a60c608e01513 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 12:14:40 +0530 Subject: [PATCH 26/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 808d8a606..288a796b1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,7 +39,7 @@ def set_relative_links(app, docname, source): source[0] = source[0].replace( '/api/google/generativeai/GenerativeModel.md', - '/index.md' + '' ) def setup(app): From a4ea6989cb8e281a518fff23623e17191702dbac Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 12:36:50 +0530 Subject: [PATCH 27/52] Update conf.py --- docs/conf.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 288a796b1..80e0146fa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,16 +31,38 @@ html_theme = 'alabaster' # html_static_path = ['_static'] + +import re + +# def set_relative_links(app, docname, source): +# # Pattern to match the GitHub links +# pattern = r'https://github\.com/vi-shruti/generative-ai-python/blob/main/docs/api/google/generativeai/(.+?)\.md(#.+)?' + +# def replace_link(match): +# file_name = match.group(1) +# anchor = match.group(2) or '' + +# # If it's the GenerativeModel file, we don't need the file name in the link +# if file_name == 'GenerativeModel': +# return f'{anchor}' +# else: +# return f'/api/google/generativeai/{file_name}{anchor}' + +# # Replace the links +# source[0] = re.sub(pattern, replace_link, source[0]) + + def set_relative_links(app, docname, source): source[0] = source[0].replace( - '../google/generativeai/', - '/api/google/generativeai/' + '../google/generativeai/GenerativeModel.md', + '' ) source[0] = source[0].replace( - '/api/google/generativeai/GenerativeModel.md', - '' + '../google/generativeai/', + '/api/google/generativeai/' ) + def setup(app): app.connect('source-read', set_relative_links) From af9ba4d9bd79012564202e684700313ed649134c Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 12:40:17 +0530 Subject: [PATCH 28/52] Update conf.py --- docs/conf.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 80e0146fa..b70dfd8ae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,33 +31,7 @@ html_theme = 'alabaster' # html_static_path = ['_static'] - -import re - -# def set_relative_links(app, docname, source): -# # Pattern to match the GitHub links -# pattern = r'https://github\.com/vi-shruti/generative-ai-python/blob/main/docs/api/google/generativeai/(.+?)\.md(#.+)?' - -# def replace_link(match): -# file_name = match.group(1) -# anchor = match.group(2) or '' - -# # If it's the GenerativeModel file, we don't need the file name in the link -# if file_name == 'GenerativeModel': -# return f'{anchor}' -# else: -# return f'/api/google/generativeai/{file_name}{anchor}' - -# # Replace the links -# source[0] = re.sub(pattern, replace_link, source[0]) - - def set_relative_links(app, docname, source): - source[0] = source[0].replace( - '../google/generativeai/GenerativeModel.md', - '' - ) - source[0] = source[0].replace( '../google/generativeai/', '/api/google/generativeai/' From 37293397794cc81fbbeb88a62b500fe6a8be8ec2 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 13:08:09 +0530 Subject: [PATCH 29/52] Update conf.py --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index b70dfd8ae..51603ae21 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,6 +3,7 @@ author = 'Google LLC' extensions = [ + 'sphinx.ext.autosectionlabel', 'sphinx.ext.coverage', 'myst_parser', 'sphinx.ext.viewcode', From 4e4ee2ed43aa9e9e3a55fe3a833ca2949b0de842 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 13:18:50 +0530 Subject: [PATCH 30/52] Update conf.py --- docs/conf.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 51603ae21..35e62cbf9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,6 @@ +import re +from docutils import nodes + project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -32,12 +35,33 @@ html_theme = 'alabaster' # html_static_path = ['_static'] -def set_relative_links(app, docname, source): - source[0] = source[0].replace( - '../google/generativeai/', - '/api/google/generativeai/' - ) +# def set_relative_links(app, docname, source): +# source[0] = source[0].replace( +# '../google/generativeai/', +# '/api/google/generativeai/' +# ) + + +# def setup(app): +# app.connect('source-read', set_relative_links) + + + +def markdown_link_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + match = re.match(r'(.*?)\s*<(.+?)>', text) + if match: + label, target = match.groups() + else: + label = text + target = text + + # Convert .md to .html and add the prefix + target = target.replace('.md#', '.html#') + target = f'/generative-ai-python{target}' if not target.startswith('/generative-ai-python') else target + url = target + node = nodes.reference(rawtext, label, refuri=url, **options) + return [node], [] def setup(app): - app.connect('source-read', set_relative_links) + app.add_role('mdlink', markdown_link_role) From e31b2c7f4b9f7ff5c338d71d4a1b829109deb197 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 13:31:55 +0530 Subject: [PATCH 31/52] Update conf.py --- docs/conf.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 35e62cbf9..0b7a1e18a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,7 @@ import re -from docutils import nodes +from sphinx.util import logging + +logger = logging.getLogger(__name__) project = 'Google Generative AI - Python' copyright = '2024, Google LLC' @@ -47,21 +49,27 @@ -def markdown_link_role(name, rawtext, text, lineno, inliner, options={}, content=[]): - match = re.match(r'(.*?)\s*<(.+?)>', text) - if match: - label, target = match.groups() - else: - label = text - target = text - # Convert .md to .html and add the prefix - target = target.replace('.md#', '.html#') - target = f'/generative-ai-python{target}' if not target.startswith('/generative-ai-python') else target +def update_internal_links(app, docname, source): + def replace_link(match): + path = match.group(1) + anchor = match.group(2) or '' + if path.endswith('.md'): + path = path[:-3] + '.html' + return f'/generative-ai-python{path}{anchor}' + + def replace_relative_path(match): + return '/api/google/generativeai/' + + # Pattern for links with potential anchors + link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' + # Pattern for relative paths + path_pattern = r'\.\.\/google\/generativeai\/' - url = target - node = nodes.reference(rawtext, label, refuri=url, **options) - return [node], [] + # Replace links + source[0] = re.sub(link_pattern, replace_link, source[0]) + # Replace relative paths + source[0] = re.sub(path_pattern, replace_relative_path, source[0]) def setup(app): - app.add_role('mdlink', markdown_link_role) + app.connect('source-read', update_internal_links) \ No newline at end of file From b27e084ec3b48cc0dce4bee1a652eb2e69b40060 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 13:48:12 +0530 Subject: [PATCH 32/52] Update conf.py --- docs/conf.py | 60 +++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0b7a1e18a..25466616c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ -import re -from sphinx.util import logging +# import re +# from sphinx.util import logging -logger = logging.getLogger(__name__) +# logger = logging.getLogger(__name__) project = 'Google Generative AI - Python' copyright = '2024, Google LLC' @@ -15,6 +15,8 @@ 'sphinx.ext.githubpages', ] +autosectionlabel_prefix_document = True + myst_url_schemes = ["http", "https", "mailto"] myst_enable_extensions = [ "colon_fence", @@ -37,39 +39,39 @@ html_theme = 'alabaster' # html_static_path = ['_static'] -# def set_relative_links(app, docname, source): -# source[0] = source[0].replace( -# '../google/generativeai/', -# '/api/google/generativeai/' -# ) +def set_relative_links(app, docname, source): + source[0] = source[0].replace( + '../google/generativeai/', + '/api/google/generativeai/' + ) -# def setup(app): -# app.connect('source-read', set_relative_links) +def setup(app): + app.connect('source-read', set_relative_links) -def update_internal_links(app, docname, source): - def replace_link(match): - path = match.group(1) - anchor = match.group(2) or '' - if path.endswith('.md'): - path = path[:-3] + '.html' - return f'/generative-ai-python{path}{anchor}' +# def update_internal_links(app, docname, source): +# def replace_link(match): +# path = match.group(1) +# anchor = match.group(2) or '' +# if path.endswith('.md'): +# path = path[:-3] + '.html' +# return f'/generative-ai-python{path}{anchor}' - def replace_relative_path(match): - return '/api/google/generativeai/' +# def replace_relative_path(match): +# return '/api/google/generativeai/' - # Pattern for links with potential anchors - link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' - # Pattern for relative paths - path_pattern = r'\.\.\/google\/generativeai\/' +# # Pattern for links with potential anchors +# link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' +# # Pattern for relative paths +# path_pattern = r'\.\.\/google\/generativeai\/' - # Replace links - source[0] = re.sub(link_pattern, replace_link, source[0]) - # Replace relative paths - source[0] = re.sub(path_pattern, replace_relative_path, source[0]) +# # Replace links +# source[0] = re.sub(link_pattern, replace_link, source[0]) +# # Replace relative paths +# source[0] = re.sub(path_pattern, replace_relative_path, source[0]) -def setup(app): - app.connect('source-read', update_internal_links) \ No newline at end of file +# def setup(app): +# app.connect('source-read', update_internal_links) \ No newline at end of file From 5d6b9bfe8037e4c31295fc782875923f28b42e1a Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 13:54:07 +0530 Subject: [PATCH 33/52] Update conf.py --- docs/conf.py | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 25466616c..9f79fa56c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,21 +1,16 @@ -# import re -# from sphinx.util import logging - -# logger = logging.getLogger(__name__) - project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' extensions = [ - 'sphinx.ext.autosectionlabel', + # 'sphinx.ext.autosectionlabel', 'sphinx.ext.coverage', 'myst_parser', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', ] -autosectionlabel_prefix_document = True +# autosectionlabel_prefix_document = True myst_url_schemes = ["http", "https", "mailto"] myst_enable_extensions = [ @@ -31,7 +26,7 @@ ] source_suffix = {'.md': 'markdown',} -master_doc = 'index' # Changed in version 2.0: Default is 'index' (previously 'contents'). +master_doc = 'index' templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] @@ -39,6 +34,7 @@ html_theme = 'alabaster' # html_static_path = ['_static'] + def set_relative_links(app, docname, source): source[0] = source[0].replace( '../google/generativeai/', @@ -48,30 +44,3 @@ def set_relative_links(app, docname, source): def setup(app): app.connect('source-read', set_relative_links) - - - - -# def update_internal_links(app, docname, source): -# def replace_link(match): -# path = match.group(1) -# anchor = match.group(2) or '' -# if path.endswith('.md'): -# path = path[:-3] + '.html' -# return f'/generative-ai-python{path}{anchor}' - -# def replace_relative_path(match): -# return '/api/google/generativeai/' - -# # Pattern for links with potential anchors -# link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' -# # Pattern for relative paths -# path_pattern = r'\.\.\/google\/generativeai\/' - -# # Replace links -# source[0] = re.sub(link_pattern, replace_link, source[0]) -# # Replace relative paths -# source[0] = re.sub(path_pattern, replace_relative_path, source[0]) - -# def setup(app): -# app.connect('source-read', update_internal_links) \ No newline at end of file From 77ad63560c8aad5d00f96aff28a158d8fccd55be Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 15:06:37 +0530 Subject: [PATCH 34/52] Update conf.py --- docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 9f79fa56c..a368dda1d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,6 +24,9 @@ "tasklist", "substitution" ] +# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors +# Controls allowable header anchors in markdown files. Value allows header anchors for h1 - h6 +myst_heading_anchors = 6 source_suffix = {'.md': 'markdown',} master_doc = 'index' From 534a0ef4309b7168bf527ba72d392efa102fc40a Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 15:11:02 +0530 Subject: [PATCH 35/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index a368dda1d..936818ec1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,7 +3,7 @@ author = 'Google LLC' extensions = [ - # 'sphinx.ext.autosectionlabel', + 'sphinx.ext.autosectionlabel', 'sphinx.ext.coverage', 'myst_parser', 'sphinx.ext.viewcode', From 1ae6e66d328e1c11e5902ca5282f1795c282a442 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 15:44:40 +0530 Subject: [PATCH 36/52] Update conf.py --- docs/conf.py | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 936818ec1..b274af80d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,8 @@ +import re +from sphinx.util import logging + +logger = logging.getLogger(__name__) + project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -38,12 +43,42 @@ # html_static_path = ['_static'] -def set_relative_links(app, docname, source): - source[0] = source[0].replace( - '../google/generativeai/', - '/api/google/generativeai/' - ) +# def set_relative_links(app, docname, source): +# source[0] = source[0].replace( +# '../google/generativeai/', +# '/api/google/generativeai/' +# ) + +# if '#' in source[0]: +# print("\n\nComing from set_relative_links: ") +# print(source[0]) +# print("==========================================\n\n") + +# def setup(app): +# app.connect('source-read', set_relative_links) + + +def update_internal_links(app, docname, source): + def replace_link(match): + path = match.group(1) + anchor = match.group(2) or '' + if path.endswith('.md'): + path = path[:-3] + '.html' + return f'/generative-ai-python{path}{anchor}' + + def replace_relative_path(match): + return '/api/google/generativeai/' + + # Pattern for links with potential anchors + link_pattern = r'(\.\.\/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' + # link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' + # Pattern for relative paths + path_pattern = r'\.\.\/google\/generativeai\/' + # Replace links + source[0] = re.sub(link_pattern, replace_link, source[0]) + # Replace relative paths + source[0] = re.sub(path_pattern, replace_relative_path, source[0]) def setup(app): - app.connect('source-read', set_relative_links) + app.connect('source-read', update_internal_links) From c5b6ae36fa66c851e86167117b990d01438d3c46 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 15:49:43 +0530 Subject: [PATCH 37/52] Update conf.py --- docs/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index b274af80d..996a7236f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,7 +64,8 @@ def replace_link(match): anchor = match.group(2) or '' if path.endswith('.md'): path = path[:-3] + '.html' - return f'/generative-ai-python{path}{anchor}' + return f'{path}{anchor}' + # return f'/generative-ai-python{path}{anchor}' def replace_relative_path(match): return '/api/google/generativeai/' From fea5e85c9d42b6117c089f518bf78208e12dc49c Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 15:58:37 +0530 Subject: [PATCH 38/52] Update conf.py --- docs/conf.py | 56 +++++++++++++--------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 996a7236f..6f7e92b5d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,3 @@ -import re -from sphinx.util import logging - -logger = logging.getLogger(__name__) - project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -11,10 +6,14 @@ 'sphinx.ext.autosectionlabel', 'sphinx.ext.coverage', 'myst_parser', + 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', ] +intersphinx_mapping = { + "sphinx": ("https://vi-shruti.github.io/generative-ai-python/", None), +} # autosectionlabel_prefix_document = True myst_url_schemes = ["http", "https", "mailto"] @@ -43,43 +42,16 @@ # html_static_path = ['_static'] -# def set_relative_links(app, docname, source): -# source[0] = source[0].replace( -# '../google/generativeai/', -# '/api/google/generativeai/' -# ) - -# if '#' in source[0]: -# print("\n\nComing from set_relative_links: ") -# print(source[0]) -# print("==========================================\n\n") - -# def setup(app): -# app.connect('source-read', set_relative_links) - - -def update_internal_links(app, docname, source): - def replace_link(match): - path = match.group(1) - anchor = match.group(2) or '' - if path.endswith('.md'): - path = path[:-3] + '.html' - return f'{path}{anchor}' - # return f'/generative-ai-python{path}{anchor}' - - def replace_relative_path(match): - return '/api/google/generativeai/' - - # Pattern for links with potential anchors - link_pattern = r'(\.\.\/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' - # link_pattern = r'(/api/google/generativeai/[\w-]+)(\.md)?(#[\w-]+)?' - # Pattern for relative paths - path_pattern = r'\.\.\/google\/generativeai\/' +def set_relative_links(app, docname, source): + source[0] = source[0].replace( + '../google/generativeai/', + '/api/google/generativeai/' + ) - # Replace links - source[0] = re.sub(link_pattern, replace_link, source[0]) - # Replace relative paths - source[0] = re.sub(path_pattern, replace_relative_path, source[0]) + if '#' in source[0]: + print("\n\nComing from set_relative_links: ") + print(source[0]) + print("==========================================\n\n") def setup(app): - app.connect('source-read', update_internal_links) + app.connect('source-read', set_relative_links) From f4097981e7384dc678f50e49e1c361f6c78cfcb3 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 16:01:06 +0530 Subject: [PATCH 39/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 6f7e92b5d..6716f23b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ ] intersphinx_mapping = { - "sphinx": ("https://vi-shruti.github.io/generative-ai-python/", None), + "generative-ai-python": ("https://vi-shruti.github.io/generative-ai-python/", None), } # autosectionlabel_prefix_document = True From 3fd0a25130e7d62f170c71b59d39f9eadb4720ed Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 16:19:16 +0530 Subject: [PATCH 40/52] Myst XRef Resolving --- .github/workflows/gh_pages_doc.yaml | 2 +- docs/conf.py | 43 +++++++++++++++++++---------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.github/workflows/gh_pages_doc.yaml b/.github/workflows/gh_pages_doc.yaml index 1b1b58166..24a76118c 100644 --- a/.github/workflows/gh_pages_doc.yaml +++ b/.github/workflows/gh_pages_doc.yaml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | - pip install sphinx myst-parser myst_nb + pip install sphinx myst-parser[linkify] myst_nb - name: Build the documentation run: | diff --git a/docs/conf.py b/docs/conf.py index 6716f23b4..f706d2fed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,5 @@ +import re + project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -6,14 +8,10 @@ 'sphinx.ext.autosectionlabel', 'sphinx.ext.coverage', 'myst_parser', - 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', ] -intersphinx_mapping = { - "generative-ai-python": ("https://vi-shruti.github.io/generative-ai-python/", None), -} # autosectionlabel_prefix_document = True myst_url_schemes = ["http", "https", "mailto"] @@ -26,7 +24,8 @@ "smartquotes", "strikethrough", "tasklist", - "substitution" + "substitution", + "linkify", ] # https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors # Controls allowable header anchors in markdown files. Value allows header anchors for h1 - h6 @@ -42,16 +41,30 @@ # html_static_path = ['_static'] -def set_relative_links(app, docname, source): - source[0] = source[0].replace( - '../google/generativeai/', - '/api/google/generativeai/' - ) +# def set_relative_links(app, docname, source): +# source[0] = source[0].replace( +# '../google/generativeai/', +# '/api/google/generativeai/' +# ) + +# # if '#' in source[0]: +# # print("\n\nComing from set_relative_links: ") +# # print(source[0]) +# # print("==========================================\n\n") + +# def setup(app): +# app.connect('source-read', set_relative_links) + + - if '#' in source[0]: - print("\n\nComing from set_relative_links: ") - print(source[0]) - print("==========================================\n\n") +def set_relative_links(app, pagename, templatename, context, doctree): + if 'body' in context: + # Perform the substitution in the HTML body + context['body'] = re.sub( + r'(\.\./google/generativeai/[^"]+)\.md(#\w+)?', + r'/api/google/generativeai/\1.html\2', + context['body'] + ) def setup(app): - app.connect('source-read', set_relative_links) + app.connect('html-page-context', set_relative_links) From 22bd52ba160d2f61b58c217bc34a75c7450cec36 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 16:22:28 +0530 Subject: [PATCH 41/52] Update conf.py --- docs/conf.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f706d2fed..cd8218257 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,30 +41,30 @@ # html_static_path = ['_static'] -# def set_relative_links(app, docname, source): -# source[0] = source[0].replace( -# '../google/generativeai/', -# '/api/google/generativeai/' -# ) +def set_relative_links(app, docname, source): + source[0] = source[0].replace( + '../google/generativeai/', + '/api/google/generativeai/' + ) -# # if '#' in source[0]: -# # print("\n\nComing from set_relative_links: ") -# # print(source[0]) -# # print("==========================================\n\n") + # if '#' in source[0]: + # print("\n\nComing from set_relative_links: ") + # print(source[0]) + # print("==========================================\n\n") -# def setup(app): -# app.connect('source-read', set_relative_links) +def setup(app): + app.connect('source-read', set_relative_links) -def set_relative_links(app, pagename, templatename, context, doctree): - if 'body' in context: - # Perform the substitution in the HTML body - context['body'] = re.sub( - r'(\.\./google/generativeai/[^"]+)\.md(#\w+)?', - r'/api/google/generativeai/\1.html\2', - context['body'] - ) +# def set_relative_links(app, pagename, templatename, context, doctree): +# if 'body' in context: +# # Perform the substitution in the HTML body +# context['body'] = re.sub( +# r'(\.\./google/generativeai/[^"]+)\.md(#\w+)?', +# r'/api/google/generativeai/\1.html\2', +# context['body'] +# ) -def setup(app): - app.connect('html-page-context', set_relative_links) +# def setup(app): +# app.connect('html-page-context', set_relative_links) From 1454d27ec816ee530afba6099adb0cb40e85d30d Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 19:26:08 +0530 Subject: [PATCH 42/52] Update conf.py --- docs/conf.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index cd8218257..21a99bd76 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -import re - project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -32,7 +30,7 @@ myst_heading_anchors = 6 source_suffix = {'.md': 'markdown',} -master_doc = 'index' +master_doc = 'api/google/generativeai' # 'index' templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] @@ -47,24 +45,6 @@ def set_relative_links(app, docname, source): '/api/google/generativeai/' ) - # if '#' in source[0]: - # print("\n\nComing from set_relative_links: ") - # print(source[0]) - # print("==========================================\n\n") - def setup(app): app.connect('source-read', set_relative_links) - - -# def set_relative_links(app, pagename, templatename, context, doctree): -# if 'body' in context: -# # Perform the substitution in the HTML body -# context['body'] = re.sub( -# r'(\.\./google/generativeai/[^"]+)\.md(#\w+)?', -# r'/api/google/generativeai/\1.html\2', -# context['body'] -# ) - -# def setup(app): -# app.connect('html-page-context', set_relative_links) From d4545dc4017ad2d0c33bdd618c52ae9d6d425c37 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 20:26:33 +0530 Subject: [PATCH 43/52] Updated conf.py --- docs/conf.py | 34 +++++++++++-- docs/index.md | 138 -------------------------------------------------- 2 files changed, 31 insertions(+), 141 deletions(-) delete mode 100644 docs/index.md diff --git a/docs/conf.py b/docs/conf.py index 21a99bd76..e72e7aa31 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,12 +39,40 @@ # html_static_path = ['_static'] + +import re + def set_relative_links(app, docname, source): - source[0] = source[0].replace( - '../google/generativeai/', - '/api/google/generativeai/' + def replace_link(match): + path = match.group(1) + anchor = match.group(2) or '' + if path.endswith('.md'): + path = path[:-3] + '.html' + return f'/api/google/generativeai/{path}{anchor}' + + # Pattern for Markdown links with optional anchors + pattern = r'\((\.\.\/google\/generativeai\/[\w-]+)(\.md)?(#[\w-]+)?\)' + + # Replace the links + source[0] = re.sub(pattern, replace_link, source[0]) + + # Replace HTML anchor links + source[0] = re.sub( + r'', + r'', + source[0] ) def setup(app): app.connect('source-read', set_relative_links) + +# def set_relative_links(app, docname, source): +# source[0] = source[0].replace( +# '../google/generativeai/', +# '/api/google/generativeai/' +# ) + +# def setup(app): +# app.connect('source-read', set_relative_links) + diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 23ee47866..000000000 --- a/docs/index.md +++ /dev/null @@ -1,138 +0,0 @@ -description: Google AI Python SDK - -
- - - - -
- -# Module: google.generativeai - - - - - - - - - -Google AI Python SDK - - - -## Setup - -```posix-terminal -pip install google-generativeai -``` - -## GenerativeModel - -Use `genai.GenerativeModel` to access the API: - -``` -import google.generativeai as genai -import os - -genai.configure(api_key=os.environ['API_KEY']) - -model = genai.GenerativeModel(model_name='gemini-1.5-flash') -response = model.generate_content('Teach me about how an LLM works') - -print(response.text) -``` - -See the [python quickstart](https://ai.google.dev/tutorials/python_quickstart) for more details. - -## Modules - -[`protos`](../google/generativeai/protos.md) module: This module provides low level access to the ProtoBuffer "Message" classes used by the API. - -[`types`](../google/generativeai/types.md) module: A collection of type definitions used throughout the library. - -## Classes - -[`class ChatSession`](../google/generativeai/ChatSession.md): Contains an ongoing conversation with the model. - -[`class GenerationConfig`](../google/generativeai/types/GenerationConfig.md): A simple dataclass used to configure the generation parameters of
GenerativeModel.generate_content. - -[`class GenerativeModel`](../google/generativeai/GenerativeModel.md): The `genai.GenerativeModel` class wraps default parameters for calls to GenerativeModel.generate_content, GenerativeModel.count_tokens, and GenerativeModel.start_chat. - -## Functions - -[`chat(...)`](../google/generativeai/chat.md): Calls the API to initiate a chat with a model using provided parameters - -[`chat_async(...)`](../google/generativeai/chat_async.md): Calls the API to initiate a chat with a model using provided parameters - -[`configure(...)`](../google/generativeai/configure.md): Captures default client configuration. - -[`count_message_tokens(...)`](../google/generativeai/count_message_tokens.md): Calls the API to calculate the number of tokens used in the prompt. - -[`count_text_tokens(...)`](../google/generativeai/count_text_tokens.md): Calls the API to count the number of tokens in the text prompt. - -[`create_tuned_model(...)`](../google/generativeai/create_tuned_model.md): Calls the API to initiate a tuning process that optimizes a model for specific data, returning an operation object to track and manage the tuning progress. - -[`delete_file(...)`](../google/generativeai/delete_file.md): Calls the API to permanently delete a specified file using a supported file service. - -[`delete_tuned_model(...)`](../google/generativeai/delete_tuned_model.md): Calls the API to delete a specified tuned model - -[`embed_content(...)`](../google/generativeai/embed_content.md): Calls the API to create embeddings for content passed in. - -[`embed_content_async(...)`](../google/generativeai/embed_content_async.md): Calls the API to create async embeddings for content passed in. - -[`generate_embeddings(...)`](../google/generativeai/generate_embeddings.md): Calls the API to create an embedding for the text passed in. - -[`generate_text(...)`](../google/generativeai/generate_text.md): Calls the API to generate text based on the provided prompt. - -[`get_base_model(...)`](../google/generativeai/get_base_model.md): Calls the API to fetch a base model by name. - -[`get_file(...)`](../google/generativeai/get_file.md): Calls the API to retrieve a specified file using a supported file service. - -[`get_model(...)`](../google/generativeai/get_model.md): Calls the API to fetch a model by name. - -[`get_operation(...)`](../google/generativeai/get_operation.md): Calls the API to get a specific operation - -[`get_tuned_model(...)`](../google/generativeai/get_tuned_model.md): Calls the API to fetch a tuned model by name. - -[`list_files(...)`](../google/generativeai/list_files.md): Calls the API to list files using a supported file service. - -[`list_models(...)`](../google/generativeai/list_models.md): Calls the API to list all available models. - -[`list_operations(...)`](../google/generativeai/list_operations.md): Calls the API to list all operations - -[`list_tuned_models(...)`](../google/generativeai/list_tuned_models.md): Calls the API to list all tuned models. - -[`update_tuned_model(...)`](../google/generativeai/update_tuned_model.md): Calls the API to push updates to a specified tuned model where only certain attributes are updatable. - -[`upload_file(...)`](../google/generativeai/upload_file.md): Calls the API to upload a file using a supported file service. - - - - - - - - - - - - - - - -
-__version__ - -`'0.7.2'` -
-annotations - -Instance of `__future__._Feature` -
- From cb11760dcf6fcaeceef223bc1bca3ab24c409ac0 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 20:33:47 +0530 Subject: [PATCH 44/52] Create index.md --- docs/api/google/index.md | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 docs/api/google/index.md diff --git a/docs/api/google/index.md b/docs/api/google/index.md new file mode 100644 index 000000000..23ee47866 --- /dev/null +++ b/docs/api/google/index.md @@ -0,0 +1,138 @@ +description: Google AI Python SDK + +
+ + + + +
+ +# Module: google.generativeai + + + + + + + + + +Google AI Python SDK + + + +## Setup + +```posix-terminal +pip install google-generativeai +``` + +## GenerativeModel + +Use `genai.GenerativeModel` to access the API: + +``` +import google.generativeai as genai +import os + +genai.configure(api_key=os.environ['API_KEY']) + +model = genai.GenerativeModel(model_name='gemini-1.5-flash') +response = model.generate_content('Teach me about how an LLM works') + +print(response.text) +``` + +See the [python quickstart](https://ai.google.dev/tutorials/python_quickstart) for more details. + +## Modules + +[`protos`](../google/generativeai/protos.md) module: This module provides low level access to the ProtoBuffer "Message" classes used by the API. + +[`types`](../google/generativeai/types.md) module: A collection of type definitions used throughout the library. + +## Classes + +[`class ChatSession`](../google/generativeai/ChatSession.md): Contains an ongoing conversation with the model. + +[`class GenerationConfig`](../google/generativeai/types/GenerationConfig.md): A simple dataclass used to configure the generation parameters of GenerativeModel.generate_content. + +[`class GenerativeModel`](../google/generativeai/GenerativeModel.md): The `genai.GenerativeModel` class wraps default parameters for calls to GenerativeModel.generate_content, GenerativeModel.count_tokens, and GenerativeModel.start_chat. + +## Functions + +[`chat(...)`](../google/generativeai/chat.md): Calls the API to initiate a chat with a model using provided parameters + +[`chat_async(...)`](../google/generativeai/chat_async.md): Calls the API to initiate a chat with a model using provided parameters + +[`configure(...)`](../google/generativeai/configure.md): Captures default client configuration. + +[`count_message_tokens(...)`](../google/generativeai/count_message_tokens.md): Calls the API to calculate the number of tokens used in the prompt. + +[`count_text_tokens(...)`](../google/generativeai/count_text_tokens.md): Calls the API to count the number of tokens in the text prompt. + +[`create_tuned_model(...)`](../google/generativeai/create_tuned_model.md): Calls the API to initiate a tuning process that optimizes a model for specific data, returning an operation object to track and manage the tuning progress. + +[`delete_file(...)`](../google/generativeai/delete_file.md): Calls the API to permanently delete a specified file using a supported file service. + +[`delete_tuned_model(...)`](../google/generativeai/delete_tuned_model.md): Calls the API to delete a specified tuned model + +[`embed_content(...)`](../google/generativeai/embed_content.md): Calls the API to create embeddings for content passed in. + +[`embed_content_async(...)`](../google/generativeai/embed_content_async.md): Calls the API to create async embeddings for content passed in. + +[`generate_embeddings(...)`](../google/generativeai/generate_embeddings.md): Calls the API to create an embedding for the text passed in. + +[`generate_text(...)`](../google/generativeai/generate_text.md): Calls the API to generate text based on the provided prompt. + +[`get_base_model(...)`](../google/generativeai/get_base_model.md): Calls the API to fetch a base model by name. + +[`get_file(...)`](../google/generativeai/get_file.md): Calls the API to retrieve a specified file using a supported file service. + +[`get_model(...)`](../google/generativeai/get_model.md): Calls the API to fetch a model by name. + +[`get_operation(...)`](../google/generativeai/get_operation.md): Calls the API to get a specific operation + +[`get_tuned_model(...)`](../google/generativeai/get_tuned_model.md): Calls the API to fetch a tuned model by name. + +[`list_files(...)`](../google/generativeai/list_files.md): Calls the API to list files using a supported file service. + +[`list_models(...)`](../google/generativeai/list_models.md): Calls the API to list all available models. + +[`list_operations(...)`](../google/generativeai/list_operations.md): Calls the API to list all operations + +[`list_tuned_models(...)`](../google/generativeai/list_tuned_models.md): Calls the API to list all tuned models. + +[`update_tuned_model(...)`](../google/generativeai/update_tuned_model.md): Calls the API to push updates to a specified tuned model where only certain attributes are updatable. + +[`upload_file(...)`](../google/generativeai/upload_file.md): Calls the API to upload a file using a supported file service. + + + + + + + + + + + + + + + +
+__version__ + +`'0.7.2'` +
+annotations + +Instance of `__future__._Feature` +
+ From 2062670c8d2e22210c40d8d83197f62764209584 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 20:41:49 +0530 Subject: [PATCH 45/52] Updated index.md --- docs/conf.py | 2 +- docs/{api/google => }/index.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/{api/google => }/index.md (100%) diff --git a/docs/conf.py b/docs/conf.py index e72e7aa31..6a66dc026 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,7 +30,7 @@ myst_heading_anchors = 6 source_suffix = {'.md': 'markdown',} -master_doc = 'api/google/generativeai' # 'index' +master_doc = 'index' #'api/google/generativeai' templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] diff --git a/docs/api/google/index.md b/docs/index.md similarity index 100% rename from docs/api/google/index.md rename to docs/index.md From 87a1ffdf858b513e052318b53581187c9363eae2 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 20:54:55 +0530 Subject: [PATCH 46/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 6a66dc026..4ab2da002 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ def replace_link(match): # Replace HTML anchor links source[0] = re.sub( - r'', + r'', r'', source[0] ) From 2d6203033b32b9fda53e63844224916b8b3069ba Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 21:16:30 +0530 Subject: [PATCH 47/52] Update conf.py --- docs/conf.py | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 4ab2da002..c90e87939 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,6 +39,14 @@ # html_static_path = ['_static'] +# def set_relative_links(app, docname, source): +# source[0] = source[0].replace( +# '../google/generativeai/', +# '/api/google/generativeai/' +# ) + +# def setup(app): +# app.connect('source-read', set_relative_links) import re @@ -50,29 +58,11 @@ def replace_link(match): path = path[:-3] + '.html' return f'/api/google/generativeai/{path}{anchor}' - # Pattern for Markdown links with optional anchors - pattern = r'\((\.\.\/google\/generativeai\/[\w-]+)(\.md)?(#[\w-]+)?\)' + # Pattern for both Markdown links and HTML anchor links + pattern = r'(?:href="|")(?:\.\.\/google\/generativeai\/)?([\w-]+\.md)(#[\w-]+)?"' # Replace the links - source[0] = re.sub(pattern, replace_link, source[0]) - - # Replace HTML anchor links - source[0] = re.sub( - r'', - r'', - source[0] - ) + source[0] = re.sub(pattern, lambda m: f'href="{replace_link(m)}"', source[0]) def setup(app): - app.connect('source-read', set_relative_links) - - -# def set_relative_links(app, docname, source): -# source[0] = source[0].replace( -# '../google/generativeai/', -# '/api/google/generativeai/' -# ) - -# def setup(app): -# app.connect('source-read', set_relative_links) - + app.connect('source-read', set_relative_links) \ No newline at end of file From 6c8fc2e5dd861a68722e34c4a1e687efe25b5b1a Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 21:20:41 +0530 Subject: [PATCH 48/52] Update conf.py --- docs/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index c90e87939..f77641b4d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,5 +64,10 @@ def replace_link(match): # Replace the links source[0] = re.sub(pattern, lambda m: f'href="{replace_link(m)}"', source[0]) + source[0] = source[0].replace( + '../google/generativeai/', + '/api/google/generativeai/' + ) + def setup(app): app.connect('source-read', set_relative_links) \ No newline at end of file From f6281688ada4eb625c578ec2e0371c8cbb98cc21 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 22:25:17 +0530 Subject: [PATCH 49/52] Update conf.py --- docs/conf.py | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f77641b4d..db315743b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,3 +1,5 @@ +import re + project = 'Google Generative AI - Python' copyright = '2024, Google LLC' author = 'Google LLC' @@ -39,35 +41,29 @@ # html_static_path = ['_static'] -# def set_relative_links(app, docname, source): -# source[0] = source[0].replace( -# '../google/generativeai/', -# '/api/google/generativeai/' -# ) - -# def setup(app): -# app.connect('source-read', set_relative_links) - -import re - def set_relative_links(app, docname, source): - def replace_link(match): - path = match.group(1) - anchor = match.group(2) or '' - if path.endswith('.md'): - path = path[:-3] + '.html' - return f'/api/google/generativeai/{path}{anchor}' - - # Pattern for both Markdown links and HTML anchor links - pattern = r'(?:href="|")(?:\.\.\/google\/generativeai\/)?([\w-]+\.md)(#[\w-]+)?"' - - # Replace the links - source[0] = re.sub(pattern, lambda m: f'href="{replace_link(m)}"', source[0]) - source[0] = source[0].replace( '../google/generativeai/', '/api/google/generativeai/' ) +def replace_md_links(app, pagename, templatename, context, doctree): + """Replaces all .md links with .html in the final HTML output.""" + if 'body' in context: + # Pattern to identify and replace links + pattern = re.compile(r'') + + # Function to replace matched .md links with .html links + def md_to_html(match): + # Get the base link and optional fragment + base_link = match.group(1) + fragment = match.group(2) or "" + # Replace .md with .html and retain the fragment if present + return f'' + + # Apply the replacement to all links in the HTML body + context['body'] = pattern.sub(md_to_html, context['body']) + def setup(app): - app.connect('source-read', set_relative_links) \ No newline at end of file + app.connect('html-page-context', replace_md_links) + app.connect('source-read', set_relative_links) From e726528e2b74741750df1e7678267cd0dab598de Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Wed, 6 Nov 2024 22:31:17 +0530 Subject: [PATCH 50/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index db315743b..a0f0b1c7f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,7 +59,7 @@ def md_to_html(match): base_link = match.group(1) fragment = match.group(2) or "" # Replace .md with .html and retain the fragment if present - return f'' + return f'' # Apply the replacement to all links in the HTML body context['body'] = pattern.sub(md_to_html, context['body']) From bab6c398a3bc0cd82a7765a5a1d5bd61a51f8338 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Thu, 7 Nov 2024 10:13:04 +0530 Subject: [PATCH 51/52] Update conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index a0f0b1c7f..3a6e84a18 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -59,7 +59,7 @@ def md_to_html(match): base_link = match.group(1) fragment = match.group(2) or "" # Replace .md with .html and retain the fragment if present - return f'' + return f'' # Apply the replacement to all links in the HTML body context['body'] = pattern.sub(md_to_html, context['body']) From 63fbdd15f62f96f6d5a3e72b37ffaa55aea897c6 Mon Sep 17 00:00:00 2001 From: Shruti Vishwakarma Date: Thu, 7 Nov 2024 10:40:40 +0530 Subject: [PATCH 52/52] Update conf.py --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index 3a6e84a18..bb06e27c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -30,6 +30,7 @@ # https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors # Controls allowable header anchors in markdown files. Value allows header anchors for h1 - h6 myst_heading_anchors = 6 +suppress_warnings = ["myst.xref_missing", "myst.iref_ambiguous"] source_suffix = {'.md': 'markdown',} master_doc = 'index' #'api/google/generativeai'