我正在尝试按照Google Docs of Vertexai的建议运行Gemini Pro:https://console.cloud.google.com/vertex-ai/publishers/google/google/model-garden/gemini-garden/gemini-pro
导入Vertexai
来自vertexai.preview。
我正在尝试按照Google docs of Vertexai的建议运行Gemini Pro:
https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/garden/gemini-pro
import vertexai
from vertexai.preview.generative_models import GenerativeModel, ChatSession
# TODO(developer): Update and un-comment below lines
project_id = "<my_project_id>"
location = "us-central1"
vertexai.init(project=project_id, location=location)
model = GenerativeModel("gemini-1.0-pro")
chat = model.start_chat(response_validation=False)
def get_chat_response(chat: ChatSession, prompt: str):
response = chat.send_message(prompt)
return response.text
for prompt in prompt_list:
print(get_chat_response(chat, prompt))
我仅通过添加
response_validation = false
。
进行了修改。
我以4,5k提示表单
stript_list
以4,5K提示表单运行此代码。
它适用于大约150个提示,然后在以下错误中破裂:
2024-03-11 08:04:47 [error ] Error in LLM request gender: 400 Request contains an invalid argument.
Traceback (most recent call last):
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 76, in error_remapped_callable
return callable_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/grpc/_channel.py", line 1176, in __call__
return _end_unary_response_blocking(state, call, False, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/grpc/_channel.py", line 1005, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B2a00:1450:401b:80e::200a%5D:443 {created_time:"2024-03-11T08:04:47.917745+01:00", grpc_status:3, grpc_message:"Request contains an invalid argument."}"
The above exception was the direct cause of the following exception
...
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/vertexai/generative_models/_generative_models.py", line 727, in send_message
return self._send_message(
^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/vertexai/generative_models/_generative_models.py", line 814, in _send_message
response = self._model._generate_content(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/vertexai/generative_models/_generative_models.py", line 435, in _generate_content
gapic_response = self._prediction_client.generate_content(request=request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py", line 2080, in generate_content
response = rpc(
^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
return wrapped_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/l028/.pyenv/versions/playground_env/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.
-
如何克服此错误?
-
这可以是我位于欧盟并使用美国
位置
?
我已经删除了验证。