v0.5.0 - Files
What's Changed
New features
-
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])
- Add initial prototype supporting the files API by @MarkDaoust in #249
- Files API: improve error messages, add delete_file, add
.uri
property by @TYMichaelChen in #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 )
- Finish Semantic Retriever. by @shilpakancharla in #230
-
System instructions
When creating a model you can pass a string (or
Content
) assystem_instructions
:genai.GenerativeModel(system_instructions="Be good!")
- Add basic SI and tool_config support by @MarkDaoust in #257
- Add
system_instruction
to model repr by @markmcd in #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 betweenNone
(No function calls),Auto
(The model chooses to return text or a FunctionCall), andAny
(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 passallowed_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.- Add basic SI and tool_config support by @MarkDaoust in #257
- Function calling mode patch by @mayureshagashe2105 in #271
Docs, bug fixes, and minor updates.
- Update README.md by @aertoria in #256
- Fix incorrect reference to self.candidates[0].parts, self.candidates[0].parts[0].text by @Andy963 in #239
- Fix TypedDict usage for compatibility with PyDantic by @MarkDaoust in #259
- Simplify the Python SDK README by @random-forests in #267
- Sdk update to use glm 0.6.1 by @mayureshagashe2105 in #270
New Contributors
- @aertoria made their first contribution in #256
- @TYMichaelChen made their first contribution in #260
- @random-forests made their first contribution in #267
Full Changelog: v0.4.1...v0.5.0