Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

google-genai[patch]: release 0.0.9, safety settings docs #17432

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 33 additions & 2 deletions docs/docs/integrations/chat/google_generative_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,51 @@
"4. Message may be blocked if they violate the safety checks of the LLM. In this case, the model will return an empty response."
]
},
{
"cell_type": "markdown",
"id": "54793b9e",
"metadata": {},
"source": [
"### Safety Settings\n",
"\n",
"Gemini models have default safety settings that can be overridden. If you are receiving lots of \"Safety Warnings\" from your models, you can try tweaking the `safety_settings` attribute of the model. For example, to turn off safety blocking for dangerous content, you can construct your LLM as follows:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "75fdfad6",
"metadata": {},
"outputs": [],
"source": []
"source": [
"from langchain_google_genai import (\n",
" ChatGoogleGenerativeAI,\n",
" HarmBlockThreshold,\n",
" HarmCategory,\n",
")\n",
"\n",
"llm = ChatGoogleGenerativeAI(\n",
" model=\"gemini-pro\",\n",
" safety_settings={\n",
" HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,\n",
" },\n",
")"
]
},
{
"cell_type": "markdown",
"id": "e68e203d",
"metadata": {},
"source": [
"For an enumeration of the categories and thresholds available, see Google's [safety setting types](https://ai.google.dev/api/python/google/generativeai/types/SafetySettingDict)."
]
},
{
"cell_type": "markdown",
"id": "92b5aca5",
"metadata": {},
"source": [
"## Additional Configuraation\n",
"## Additional Configuration\n",
"\n",
"You can pass the following parameters to ChatGoogleGenerativeAI in order to customize the SDK's behavior:\n",
"\n",
Expand Down
32 changes: 30 additions & 2 deletions docs/docs/integrations/llms/google_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,41 @@
" sys.stdout.flush()"
]
},
{
"cell_type": "markdown",
"id": "aefe6df7",
"metadata": {},
"source": [
"### Safety Settings\n",
"\n",
"Gemini models have default safety settings that can be overridden. If you are receiving lots of \"Safety Warnings\" from your models, you can try tweaking the `safety_settings` attribute of the model. For example, to turn off safety blocking for dangerous content, you can construct your LLM as follows:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aefe6df7",
"id": "7e2682e6",
"metadata": {},
"outputs": [],
"source": []
"source": [
"from langchain_google_genai import GoogleGenerativeAI, HarmBlockThreshold, HarmCategory\n",
"\n",
"llm = GoogleGenerativeAI(\n",
" model=\"gemini-pro\",\n",
" google_api_key=api_key,\n",
" safety_settings={\n",
" HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,\n",
" },\n",
")"
]
},
{
"cell_type": "markdown",
"id": "e8d0ee0b",
"metadata": {},
"source": [
"For an enumeration of the categories and thresholds available, see Google's [safety setting types](https://ai.google.dev/api/python/google/generativeai/types/SafetySettingDict)."
]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"id": "2e7857e5",
"metadata": {},
"source": [
"## Additional Configuraation\n",
"## Additional Configuration\n",
"\n",
"You can pass the following parameters to ChatGoogleGenerativeAI in order to customize the SDK's behavior:\n",
"\n",
Expand Down
8 changes: 4 additions & 4 deletions libs/partners/google-genai/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-google-genai"
version = "0.0.8"
version = "0.0.9"
description = "An integration package connecting Google's genai package and LangChain"
authors = []
readme = "README.md"
Expand Down Expand Up @@ -70,9 +70,9 @@ types-google-cloud-ndb = "^2.2.0.1"

[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"T201", # print
]

Expand Down