Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 705068831
  • Loading branch information
Googler authored and sasha-gitg committed Dec 11, 2024
1 parent 2430171 commit 1ed0af8
Show file tree
Hide file tree
Showing 14 changed files with 1,347 additions and 245 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Google Gen AI SDK

[![PyPI version](https://img.shields.io/pypi/v/google-genai.svg)](https://pypi.org/project/google-genai/)

--------
**Documentation:** https://googleapis.github.io/python-genai/

-----

## Imports

``` python
Expand Down
44 changes: 27 additions & 17 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,12 @@ Support for generate image in Google AI is behind an allowlist
# Generate Image
response1 = client.models.generate_image(
model='imagen-3.0-generate-001',
prompt='Robot holding a red skateboard',
prompt='An umbrella in the foreground, and a rainy night sky in the background',
config=types.GenerateImageConfig(
negative_prompt= "human",
number_of_images= 1,
person_generation= "ALLOW_ADULT",
safety_filter_level= "BLOCK_LOW_AND_ABOVE",
include_rai_reason= True,
add_watermark= True,
aspect_ratio= "4:3"
output_mime_type= "image/jpeg"
)
)
response1.generated_images[0].image.show()
Expand All @@ -375,8 +373,7 @@ Upscale Image

.. code:: python
# Upscale the generated image from the cell above
from google.genai.types import Image
# Upscale the generated image from above
response2 = client.models.upscale_image(
model='imagen-3.0-generate-001',
image=response1.generated_images[0].image,
Expand All @@ -389,20 +386,33 @@ Edit Image

.. code:: python
# Edit the generated image from the first cell
from google.genai.types import Image
# Edit the generated image from above
from google.genai.types import RawReferenceImage, MaskReferenceImage
raw_ref_image = RawReferenceImage(
reference_id=1,
reference_image=response1.generated_images[0].image,
)
# Model computes a mask of the background
mask_ref_image = MaskReferenceImage(
reference_id=2,
config=types.MaskReferenceConfig(
mask_mode='MASK_MODE_BACKGROUND',
mask_dilation=0,
),
)
response3 = client.models.edit_image(
model='imagegeneration@006',
prompt='holding yellow surfboard',
image=response1.generated_images[0].image,
model='imagen-3.0-capability-preview-0930',
prompt='Sunlight and clear sky',
reference_images=[raw_ref_image, mask_ref_image],
config=types.EditImageConfig(
edit_mode="inpainting-insert",
mask_type="semantic",
segmentation_classes=[156],
edit_mode= 'EDIT_MODE_INPAINT_INSERTION',
number_of_images= 1,
negative_prompt= 'human',
include_rai_reason= True,
product_position="reposition"
)
output_mime_type= 'image/jpeg',
),
)
response3.generated_images[0].image.show()
Expand Down
6 changes: 0 additions & 6 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
@import url('https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap');

body {
font-family: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 400;
}

.main {
font-family: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

h1 {
font-size: 32px;
font-weight: 400;
Expand All @@ -34,6 +29,5 @@ h4 {
}

.highlight {
font-family: Roboto Mono, "Helvetica Neue Mono", monospace;
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2);
}
1,238 changes: 1,045 additions & 193 deletions docs/genai.html

Large diffs are not rendered by default.

31 changes: 28 additions & 3 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=354aac6f" />
<link rel="stylesheet" type="text/css" href="_static/autodoc_pydantic.css?v=a0a71c94" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=302659d7" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=10df8095" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=fdc8595f" />



Expand All @@ -18,6 +18,9 @@
body {
--color-code-background: #f8f8f8;
--color-code-foreground: black;
--font-stack: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-stack--monospace: Roboto Mono, "Helvetica Neue Mono", monospace;
--font-stack--headings: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--color-brand-primary: black;
--color-brand-content: black;

Expand All @@ -26,6 +29,9 @@
body[data-theme="dark"] {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
--font-stack: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-stack--monospace: Roboto Mono, "Helvetica Neue Mono", monospace;
--font-stack--headings: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--color-brand-primary: white;
--color-brand-content: white;

Expand All @@ -34,6 +40,9 @@
body:not([data-theme="light"]) {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
--font-stack: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-stack--monospace: Roboto Mono, "Helvetica Neue Mono", monospace;
--font-stack--headings: "Google Sans Text", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
--color-brand-primary: white;
--color-brand-content: white;

Expand Down Expand Up @@ -1290,8 +1299,6 @@ <h2>F</h2>
<li><a href="genai.html#genai.types.SchemaDict.format">(genai.types.SchemaDict attribute)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="genai.html#genai.types.GenerateContentConfig.frequency_penalty">frequency_penalty (genai.types.GenerateContentConfig attribute)</a>

<ul>
Expand All @@ -1302,13 +1309,17 @@ <h2>F</h2>
<li><a href="genai.html#genai.types.GenerationConfigDict.frequency_penalty">(genai.types.GenerationConfigDict attribute)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="genai.html#genai.types.Part.from_bytes">from_bytes() (genai.types.Part class method)</a>
</li>
<li><a href="genai.html#genai.types.Part.from_code_execution_result">from_code_execution_result() (genai.types.Part class method)</a>
</li>
<li><a href="genai.html#genai.types.Part.from_executable_code">from_executable_code() (genai.types.Part class method)</a>
</li>
<li><a href="genai.html#genai.types.Image.from_file">from_file() (genai.types.Image static method)</a>
</li>
<li><a href="genai.html#genai.types.FunctionDeclaration.from_function">from_function() (genai.types.FunctionDeclaration static method)</a>
</li>
<li><a href="genai.html#genai.types.Part.from_function_call">from_function_call() (genai.types.Part class method)</a>
</li>
Expand Down Expand Up @@ -1693,6 +1704,10 @@ <h2>H</h2>
<li><a href="genai.html#genai.types.EditImageConfig.http_options">(genai.types.EditImageConfig attribute)</a>
</li>
<li><a href="genai.html#genai.types.EditImageConfigDict.http_options">(genai.types.EditImageConfigDict attribute)</a>
</li>
<li><a href="genai.html#genai.types.EmbedContentConfig.http_options">(genai.types.EmbedContentConfig attribute)</a>
</li>
<li><a href="genai.html#genai.types.EmbedContentConfigDict.http_options">(genai.types.EmbedContentConfigDict attribute)</a>
</li>
<li><a href="genai.html#genai.types.GenerateImageConfig.http_options">(genai.types.GenerateImageConfig attribute)</a>
</li>
Expand Down Expand Up @@ -1751,6 +1766,16 @@ <h2>H</h2>
<h2>I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="genai.html#genai.types.FunctionCall.id">id (genai.types.FunctionCall attribute)</a>

<ul>
<li><a href="genai.html#genai.types.FunctionCallDict.id">(genai.types.FunctionCallDict attribute)</a>
</li>
<li><a href="genai.html#genai.types.FunctionResponse.id">(genai.types.FunctionResponse attribute)</a>
</li>
<li><a href="genai.html#genai.types.FunctionResponseDict.id">(genai.types.FunctionResponseDict attribute)</a>
</li>
</ul></li>
<li><a href="genai.html#genai.types.LiveServerToolCallCancellation.ids">ids (genai.types.LiveServerToolCallCancellation attribute)</a>

<ul>
Expand Down
Loading

0 comments on commit 1ed0af8

Please sign in to comment.