Функция вызова Google/генеративного AI не работает ⇐ Python
Функция вызова Google/генеративного AI не работает
I want to use function calling as tools in generative AI. Here are more details about function calling in Gemini and a correct structure of tool property.
Function calling would allow Gemini to call functions instead of a text response, just like ChatGPT.
I have written the following code:
import google.generativeai as genai datas = { "contents": { "role": "user", "parts": { "text": "Where can I watch Oppenheimer today?" } }, "tools": [ { "function_declarations": [ { "name": "find_movies", "description": "find movie titles currently playing in theaters based on any description, genre, title words, etc.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "description": { "type": "string", "description": "Any kind of description including category or genre, title words, attributes, etc." } }, "required": [ "description" ] } } ] } ] } genai.configure(api_key="MY_API_KEY") model = genai.GenerativeModel('gemini-1.0-pro') response = model.generate_content( **datas ) and I have the following error:
Traceback (most recent call last): File "...\main.py", line 42, in response = model.generate_content( File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\generativeai\generative_models.py", line 234, in generate_content request = self._prepare_request( File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\generativeai\generative_models.py", line 215, in _prepare_request return glm.GenerateContentRequest( TypeError: google.ai.generativelanguage_v1beta.types.generative_service.GenerateContentRequest() got multiple values for keyword argument 'tools'
Источник: https://stackoverflow.com/questions/780 ... oesnt-work
I want to use function calling as tools in generative AI. Here are more details about function calling in Gemini and a correct structure of tool property.
Function calling would allow Gemini to call functions instead of a text response, just like ChatGPT.
I have written the following code:
import google.generativeai as genai datas = { "contents": { "role": "user", "parts": { "text": "Where can I watch Oppenheimer today?" } }, "tools": [ { "function_declarations": [ { "name": "find_movies", "description": "find movie titles currently playing in theaters based on any description, genre, title words, etc.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" }, "description": { "type": "string", "description": "Any kind of description including category or genre, title words, attributes, etc." } }, "required": [ "description" ] } } ] } ] } genai.configure(api_key="MY_API_KEY") model = genai.GenerativeModel('gemini-1.0-pro') response = model.generate_content( **datas ) and I have the following error:
Traceback (most recent call last): File "...\main.py", line 42, in response = model.generate_content( File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\generativeai\generative_models.py", line 234, in generate_content request = self._prepare_request( File "...\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\generativeai\generative_models.py", line 215, in _prepare_request return glm.GenerateContentRequest( TypeError: google.ai.generativelanguage_v1beta.types.generative_service.GenerateContentRequest() got multiple values for keyword argument 'tools'
Источник: https://stackoverflow.com/questions/780 ... oesnt-work
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как избежать многократного вызова обратного вызова onClick Jetpack Compose
Anonymous » » в форуме Android - 0 Ответы
- 54 Просмотры
-
Последнее сообщение Anonymous
-