Add note on ModelInfo for Gemini Models (#6259)

<!-- Thank you for your contribution! Please review
https://microsoft.github.io/autogen/docs/Contribute before opening a
pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?

Add note on how to update modelinfo for new models.

<!-- Please give a short summary of the change and the problem this
solves. -->

## Related issue number

<!-- For example: "Closes #1234" -->

Closes #6258

## Checks

- [ ] I've included any doc changes needed for
<https://microsoft.github.io/autogen/>. See
<https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to
build and test documentation locally.
- [ ] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [ ] I've made sure all auto checks have passed.
This commit is contained in:
Victor Dibia 2025-04-10 08:53:22 -07:00 committed by GitHub
parent 7abbdc8a6d
commit 1226a4f763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 1 deletions

View File

@ -373,6 +373,7 @@
"```{note}\n",
"While some model providers may offer OpenAI-compatible APIs, they may still have minor differences.\n",
"For example, the `finish_reason` field may be different in the response.\n",
"\n",
"```"
]
},
@ -403,6 +404,29 @@
"await model_client.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Also, as Gemini adds new models, you may need to define the models capabilities via the model_info field. For example, to use `gemini-2.0-flash-lite` or a similar new model, you can use the following code:\n",
"\n",
"```python \n",
"from autogen_core.models import UserMessage\n",
"from autogen_ext.models.openai import OpenAIChatCompletionClient\n",
"from autogen_core.models import ModelInfo\n",
"\n",
"model_client = OpenAIChatCompletionClient(\n",
" model=\"gemini-2.0-flash-lite\",\n",
" model_info=ModelInfo(vision=True, function_calling=True, json_output=True, family=\"unknown\", structured_output=True)\n",
" # api_key=\"GEMINI_API_KEY\",\n",
")\n",
"\n",
"response = await model_client.create([UserMessage(content=\"What is the capital of France?\", source=\"user\")])\n",
"print(response)\n",
"await model_client.close()\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -516,7 +540,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.11.9"
}
},
"nbformat": 4,