cheshire-cat-ai / core

Production ready AI agent framework
https://cheshirecat.ai
GNU General Public License v3.0
2.28k stars 304 forks source link

[BUG] Using Gemini LLM allows you to just get one result #827

Closed mottolini closed 4 months ago

mottolini commented 4 months ago

Describe the bug If you setup Gemini LLM (using develop branch as of 17 May 24 - see https://github.com/cheshire-cat-ai/core/issues/822) you can ask just one question to the Cat, because the second one returns an error

To Reproduce Steps to reproduce the behavior:

  1. start the Cheshire Cat with docker compose up
  2. configure it to use Gemini
  3. Ask anyhting -> you get a response
  4. Ask something else -> you get an error

Additional context This is the error returned:

Screenshot 2024-05-17 at 08 05 52

Here is the log:

cheshire_cat_core  | [2024-05-17 06:10:31.022] ERROR  cat.looking_glass.stray_cat.StrayCat.__call__::349 
cheshire_cat_core  | "Invalid argument provided to Gemini: 400 Developer instruction is not enabled for models/gemini-pro"
cheshire_cat_core  | [2024-05-17 06:10:31.023] ERROR  cat.looking_glass.stray_cat.StrayCat.run::411 
cheshire_cat_core  | ChatGoogleGenerativeAIError('Invalid argument provided to Gemini: 400 Developer instruction is not enabled for models/gemini-pro')
cheshire_cat_core  | Traceback (most recent call last):
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 153, in _chat_with_retry
cheshire_cat_core  |     return generation_method(**kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 496, in send_message
cheshire_cat_core  |     response = self.model.generate_content(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/generativeai/generative_models.py", line 262, in generate_content
cheshire_cat_core  |     response = self._client.generate_content(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 812, in generate_content
cheshire_cat_core  |     response = rpc(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
cheshire_cat_core  |     return wrapped_func(*args, **kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func
cheshire_cat_core  |     return retry_target(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 153, in retry_target
cheshire_cat_core  |     _retry_error_helper(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/retry/retry_base.py", line 212, in _retry_error_helper
cheshire_cat_core  |     raise final_exc from source_exc
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
cheshire_cat_core  |     result = target()
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/timeout.py", line 120, in func_with_timeout
cheshire_cat_core  |     return func(*args, **kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
cheshire_cat_core  |     raise exceptions.from_grpc_error(exc) from exc
cheshire_cat_core  | google.api_core.exceptions.InvalidArgument: 400 Developer instruction is not enabled for models/gemini-pro
cheshire_cat_core  | 
cheshire_cat_core  | The above exception was the direct cause of the following exception:
cheshire_cat_core  | 
cheshire_cat_core  | Traceback (most recent call last):
cheshire_cat_core  |   File "/app/cat/looking_glass/stray_cat.py", line 404, in run
cheshire_cat_core  |     cat_message = self.loop.run_until_complete(
cheshire_cat_core  |   File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
cheshire_cat_core  |   File "/app/cat/looking_glass/stray_cat.py", line 351, in __call__
cheshire_cat_core  |     raise e
cheshire_cat_core  |   File "/app/cat/looking_glass/stray_cat.py", line 341, in __call__
cheshire_cat_core  |     cat_message = await self.agent_manager.execute_agent(self)
cheshire_cat_core  |   File "/app/cat/looking_glass/agent_manager.py", line 312, in execute_agent
cheshire_cat_core  |     memory_chain_output = await self.execute_memory_chain(
cheshire_cat_core  |   File "/app/cat/looking_glass/agent_manager.py", line 230, in execute_memory_chain
cheshire_cat_core  |     output = memory_chain.invoke(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 2499, in invoke
cheshire_cat_core  |     input = step.invoke(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 158, in invoke
cheshire_cat_core  |     self.generate_prompt(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 560, in generate_prompt
cheshire_cat_core  |     return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 421, in generate
cheshire_cat_core  |     raise e
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 411, in generate
cheshire_cat_core  |     self._generate_with_cache(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 632, in _generate_with_cache
cheshire_cat_core  |     result = self._generate(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 666, in _generate
cheshire_cat_core  |     response: genai.types.GenerateContentResponse = _chat_with_retry(
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 171, in _chat_with_retry
cheshire_cat_core  |     return _chat_with_retry(**kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 330, in wrapped_f
cheshire_cat_core  |     return self(f, *args, **kw)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 467, in __call__
cheshire_cat_core  |     do = self.iter(retry_state=retry_state)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 368, in iter
cheshire_cat_core  |     result = action(retry_state)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 390, in <lambda>
cheshire_cat_core  |     self._add_action_func(lambda rs: rs.outcome.result())
cheshire_cat_core  |   File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result
cheshire_cat_core  |     return self.__get_result()
cheshire_cat_core  |   File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
cheshire_cat_core  |     raise self._exception
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 470, in __call__
cheshire_cat_core  |     result = fn(*args, **kwargs)
cheshire_cat_core  |   File "/usr/local/lib/python3.10/site-packages/langchain_google_genai/chat_models.py", line 165, in _chat_with_retry
cheshire_cat_core  |     raise ChatGoogleGenerativeAIError(
cheshire_cat_core  | langchain_google_genai.chat_models.ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 Developer instruction is not enabled for models/gemini-pro
pieroit commented 4 months ago

Fixed that, a new one came out

image

If you are using a vpn, try this config (the default now): image

Not giving priority to Gemini for two reasons: 1 - most users want OpenAI or local Ollama 2 - seems Gemini not yet available in Italy?