gptscript-ai / gemini-aistudio-provider

1 stars 1 forks source link

`google.api_core.exceptions.InvalidArgument` error seen when executing scripts. #1

Closed sangee2004 closed 3 months ago

sangee2004 commented 3 months ago

Steps to reproduce the problem:

  1. Execute the following gptscript - gptscript --debug --default-model='gemini-1.0-pro from github.com/gptscript-ai/google-provider' examples/bob.gpt
  2. This fails with following error
    google.api_core.exceptions.InvalidArgument: 400 * GenerateContentRequest.generation_config.response_schema.type: field predicate failed: $ != TYPE_UNSPECIFIED

Debug logs:

INFO:     127.0.0.1:59023 - "POST /v1/chat/completions HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/base.py", line 189, in __call__
    with collapse_excgroups():
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/python/d8b978938c1563e4ea7ed3cb9b9ccf737cc104e0282b619c1b4581db09a896fa/python/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/_utils.py", line 93, in collapse_excgroups
    raise exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/fb904c97e74708130cae44dfa951fe6f03e61368/python3.12/main.py", line 35, in log_body
    return await call_next(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/fb904c97e74708130cae44dfa951fe6f03e61368/python3.12/main.py", line 205, in chat_completion
    response = model.generate_content(contents=messages,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/generativeai/generative_models.py", line 256, in generate_content
    iterator = self._client.stream_generate_content(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 1107, in stream_generate_content
    response = rpc(
               ^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func
    return retry_target(
           ^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/retry/retry_unary.py", line 153, in retry_target
    _retry_error_helper(
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/retry/retry_base.py", line 212, in _retry_error_helper
    raise final_exc from source_exc
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
    result = target()
             ^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/timeout.py", line 120, in func_with_timeout
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/66b7f14a0c7b4db9aa082536de78d354abcf0ed107836ff95956b6f5728bf32e/lib/python3.12/site-packages/google/api_core/grpc_helpers.py", line 174, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InvalidArgument: 400 * GenerateContentRequest.generation_config.response_schema.type: field predicate failed: $ != TYPE_UNSPECIFIED

{
  "err": "error, status code: 500, message: Internal Server Error",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "",
  "runID": "1715971208",
  "time": "2024-05-17T11:40:09-07:00"
}
{
  "level": "debug",
  "logger": "/Users/sangeethahariharan/gptscript/main.go",
  "msg": "failed running daemon: signal: killed",
  "time": "2024-05-17T11:40:09-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/engine",
  "msg": "daemon exited tool [Google Model Provider] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/fb904c97e74708130cae44dfa951fe6f03e61368/python3.12/main.py]: context canceled",
  "time": "2024-05-17T11:40:09-07:00"
}
2024/05/17 11:40:09 error, status code: 500, message: Internal Server Error
sangee2004 commented 3 months ago

This works as expected with latest provider.

gptscript --disable-cache --debug --default-model='gemini-pro from [github.com/gptscript-ai/gemini-aistudio-provider](http://github.com/gptscript-ai/gemini-aistudio-provider)' examples/bob.gpt