griptape-ai / griptape

Modular Python framework for AI agents and workflows with chain-of-thought reasoning, tools, and memory.
https://www.griptape.ai
Apache License 2.0
1.98k stars 163 forks source link

model gpt-4 does not exist error #26

Closed andywenk closed 1 year ago

andywenk commented 1 year ago

Hey again,

thanx for fixing the docs. It works very well. I stumbled into another issue when running the code for Agent:

(base) ➜  griptape: python agent.py
[05/09/23 19:37:28] INFO     Task 763acc754437403f9e17b36dc73e17f2
                             Input: Give me a summary of https://en.wikipedia.org/wiki/Large_language_model
ERROR:root:PromptDriver.run attempt 0 failed: The model: `gpt-4` does not exist
Retrying in 1 seconds
[...]
File "/Users/++++/miniconda/lib/python3.10/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: The model: `gpt-4` does not exist

I would love to check this out by myself and find the error but unfortunately, I am new to this kinda stuff ;-)

Thanks for any hint.

Best

Andy

kyleroche commented 1 year ago

Hi Andy, do you have access to gpt-4 yet? You can just remove that prompt driver line and it'll default to 3.5 automatically.

andywenk commented 1 year ago

yes I have access to gpt-4 but obviously not via API ^^

curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY" | grep "gpt-"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0      "id": "gpt-3.5-turbo",
      "root": "gpt-3.5-turbo",
      "id": "gpt-3.5-turbo-0301",
      "root": "gpt-3.5-turbo-0301",
100 43017  100 43017    0     0  54669      0 --:--:-- --:--:-- --:--:-- 54938 

May I ask what I need to do to also get access to gpt-4? I created a new key already

kyleroche commented 1 year ago

That is a good question :) It's unclear how OpenAI is granting access. gpt-3.5-turbo works pretty well for most cases w/ tools attached. If you remove prompt driver, does your code run now against 3.5?

andywenk commented 1 year ago

ok thanks - I will try to figure out how to get gpt-4

Erm, basically it works now, but I get another error:

[05/09/23 22:06:56] ERROR    Task 37eca2156b9144489f6210d34e86c8fa
                             0 is less than the minimum of 1 - 'max_tokens'
                             Traceback (most recent call last):
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/tasks/base_task.py", line 105, in execute
                                 self.output = self.run()
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/tasks/toolkit_task.py", line 74, in run
                                 self.active_driver().run(value=self.structure.to_prompt_string(self)).value
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/drivers/prompt/base_prompt_driver.py", line 32, in run
                                 raise e
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/drivers/prompt/base_prompt_driver.py", line 25, in run
                                 return self.try_run(**kwargs)
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/drivers/prompt/openai_prompt_driver.py", line 33, in
                             try_run
                                 return self.__run_chat(value)
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/griptape/drivers/prompt/openai_prompt_driver.py", line 38, in
                             __run_chat
                                 result = openai.ChatCompletion.create(
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
                                 return super().create(*args, **kwargs)
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153,
                             in create
                                 response, _, api_key = requestor.request(
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/openai/api_requestor.py", line 230, in request
                                 resp, got_stream = self._interpret_response(result, stream)
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/openai/api_requestor.py", line 624, in _interpret_response
                                 self._interpret_response_line(
                               File "/Users/andreaswenk/miniconda/lib/python3.10/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
                                 raise self.handle_error_response(
                             openai.error.InvalidRequestError: 0 is less than the minimum of 1 - 'max_tokens'
kyleroche commented 1 year ago

Okay, that doc wasn't using a Ramp. We have an abstraction called Ramps that helps minimize what is being sent back over the prompt. I updated the example. We are working on getting the docs up to date. We have a new version going out today and we'll update the docs right after that. But, added a ramp to the Agent example you're using.

kyleroche commented 1 year ago

Just for more context... Ramps are tool wrappers that control data flows between LLMs and the underlying customer data and APIs. Ramps allow for data compression, sanitization, side storage, and obfuscation. Griptape enables LLMs to access ramps directly depending on the context as opposed to relying on the human programmer to connect storage/compression/obfuscation direct (as they have to in other frameworks)

andywenk commented 1 year ago

Ok thanks. What do I have to install to make the MemoryStorageDriver available

NameError: name 'MemoryStorageDriver' is not defined

I could not find a pip package

UPDATE: I think this will be in the next release of griptape-tools ...

kyleroche commented 1 year ago

Arg. from griptape.drivers import MemoryStorageDriver. I'll make sure that's in the docs.

andywenk commented 1 year ago

YAY - that's it ... works great ;-)