The official Python library for the Google Gemini API
APACHE-2.0 License
Bot releases are hidden (Show)
list_models
by @rozha in https://github.com/google-gemini/generative-ai-python/pull/439
samples/files.py
by @shilpakancharla in https://github.com/google-gemini/generative-ai-python/pull/414
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.7.1...v0.7.2
Published by MarkDaoust 4 months ago
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.7.0...v0.7.1
Published by markmcd 4 months ago
For a detailed introduction, check out the context caching guide on the site.
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.6.0...v0.7.0
Published by MarkDaoust 5 months ago
genai.protos
to discourage direct use of google.ai.generativelanguage by @MarkDaoust in https://github.com/google-gemini/generative-ai-python/pull/354
safety_settings="block_none"
by @MarkDaoust in https://github.com/google-gemini/generative-ai-python/pull/347
contents
. by @MarkDaoust in https://github.com/google-gemini/generative-ai-python/pull/342
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.5.4...v0.6.0
Published by MarkDaoust 5 months ago
Published by MarkDaoust 5 months ago
update_time defined twice hence removing once. by @PandasPirate in https://github.com/google-gemini/generative-ai-python/pull/301
Add main async code match test by @mayureshagashe2105 in https://github.com/google-gemini/generative-ai-python/pull/299
Copy test cases over for new responder.py by @shilpakancharla in https://github.com/google-gemini/generative-ai-python/pull/303
Add f to f-string by @markmcd in https://github.com/google-gemini/generative-ai-python/pull/322
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.5.2...v0.5.3
Published by MarkDaoust 6 months ago
TaskTypes
and output_dimensionality
param by @mayureshagashe2105 in https://github.com/google-gemini/generative-ai-python/pull/285
Full Changelog: https://github.com/google-gemini/generative-ai-python/compare/v0.5.1...v0.5.2
Published by MarkDaoust 6 months ago
Full Changelog: https://github.com/google/generative-ai-python/compare/v0.5.0...v0.5.1
Published by MarkDaoust 6 months ago
Files API
You can now upload files to the api. Then instead of resending an image with each request, just pass a file reference in your prompt:
f = genai.upload_file(path="image.png")
m = genai.GenerativeModel(model_name=...)
response = m.generate_content(["Please describe this file:", f])
.uri
property by @TYMichaelChen in https://github.com/google/generative-ai-python/pull/260
Semantic retriever
Using answer.generate_answer
, you can now either pass "inline_passages" to include the reference material in the request:
from google.generativeai import answer
answer.generate_answer(
content=question,
inline_passages=splitter.split(document)
)
Or pass a reference to a retriever Document or Corpus:
from google.generativeai import answer
from google.generativeai import retriever
my_corpus = retriever.get_corpus('my_corpus')
genai.generate_answer(
content=question,
semantic_retreiver=my_corpus
)
System instructions
When creating a model you can pass a string (or Content
) as system_instructions
: genai.GenerativeModel(system_instructions="Be good!")
system_instruction
to model repr by @markmcd in https://github.com/google/generative-ai-python/pull/272
Function Calling - Tool Config
The list of tools available for function calling during a chat session is typically constant. The new tool_config
argument lets you switch the function calling mode between None
(No function calls), Auto
(The model chooses to return text or a FunctionCall), and Any
(the model must call a function).
model = genai.GenerativeModel(tools=[my_functions])
chat = model.start_chat()
chat.send_message(tool_config={"function_calling_config": "ANY"})
In Any
mode the model will return a function call. You may also pass allowed_function_names
to restrict the calls to a subset of the available functions: `chat.send_message(tool_config={"function_calling_config": "ANY", "allowed_function_names": [...]})
In Any
mode the model can use constrained decoding to more strictly follow the argument specifications in the function declarations.
Full Changelog: https://github.com/google/generative-ai-python/compare/v0.4.1...v0.5.0
Published by MarkDaoust 7 months ago
Full Changelog: https://github.com/google/generative-ai-python/compare/v0.4.0...v0.4.1
Published by MarkDaoust 8 months ago
genai.generate_answer
) by @shilpakancharla in https://github.com/google/generative-ai-python/pull/169
model = genai.GenerativeModel(..., tools=[my_function])
chat = model.start_chat(enable_automatic_function_calling=True)
Model.generate_content(...,
request_options={'timeout': 100, 'retry': google.api_core.retry.Retry()})
README.md
and generate_content
documentation by @Hamza-nabil in https://github.com/google/generative-ai-python/pull/149
parts
are returned by @markmcd in https://github.com/google/generative-ai-python/pull/180
embed_content_async
implementation by @mayureshagashe2105 in https://github.com/google/generative-ai-python/pull/189
__repr__
for GenerateContentResponse
and ChatSession
by @aidoskanapyanov in https://github.com/google/generative-ai-python/pull/202
Full Changelog: https://github.com/google/generative-ai-python/compare/v0.3.2...v0.4.0
Published by MarkDaoust 10 months ago
Fix GenerativeModel.count_tokens
.
Add basic function call support.
Fix async streaming with python 3.9.
Use typing_extensions for TypedDict.
Fix docs and error messages.
Full Changelog: https://github.com/google/generative-ai-python/compare/v0.3.1...v0.3.2
Published by MarkDaoust 10 months ago
Doc and Bug fixes.
Published by MarkDaoust 10 months ago
Adds the Content
family of methods to support Gemini models.
Published by MarkDaoust 12 months ago
embed_text
.types.ModelNameOptions
.count_text_tokens
metadata
(HTML headers).Published by MarkDaoust about 1 year ago
[{"category": category, "threshold": threshold}, ...]
).Published by MarkDaoust over 1 year ago
Published by MarkDaoust over 1 year ago