SuperAGI
SuperAGI copied to clipboard
OpenAI API Key encryption / decryption causing API key issues
Hi all, very cool tool but I did hit the following pain point when getting it set up.
I cloned this repo today and when I tried to run an agent the UI was stuck constantly "thinking..."
I looked at the console logs and noticed that SuperAGI was getting an error back from OpenAI that I my API key was being rate limited but when I checked my OpenAI account, no requests had been made at all.
I was, however, able to make REST queries against OpenAI directly through curl so I went into the OpenAI
class and just hard coded my api key which made SuperAGI work fine.
https://github.com/TransformerOptimus/SuperAGI/blob/ff4067a4e3b972ec2b1001d16c1b2210f7c93da9/superagi/llms/openai.py#L23
I ran a blame
on that particular line of code and it looks like it was recently modified to support fetching encrypted API keys from the database.
https://github.com/TransformerOptimus/SuperAGI/commit/8302f38cdeb6e43f03031f7ee80893557d07ed6f
I don't know the reason this is breaking but I do know that bypassing all the new database logic by hardcoding the key worked so I'm guessing it's related to these recent changes.
Would it be possible to set this as an environment variable?
@btello can we discuss this over the voice channel on Discord to understand it better? https://discord.gg/ErBU4Ba9
@pallasite99 even passing in confi.yaml file should work if nothing has been set in frontend settings.
@luciferlinx101 sure I just messaged you on Discord.
@btello is this issue resolved?
No, I'm still having the same issue. I did a pull to get the most recent version of the code base but I'm still finding that I have to override the api_key
setting in OpenAi
s constructor with my static API key to get my agent to do anything. Without that in place I just keep getting this error message:
superagi-celery-1 | Ensure the response can be parsed by Python json.loads.
superagi-celery-1 | [2023-06-27 16:40:00,850: INFO/ForkPoolWorker-8] error_code=None error_message='You exceeded your current quota, please check your plan and billing details.' error_param=None error_type=insufficient_quota message='OpenAI API error received' stream_error=False
superagi-celery-1 | 2023-06-27 16:40:00 UTC - Super AGI - INFO - [/app/superagi/llms/openai.py:80] - Exception:
superagi-celery-1 | [2023-06-27 16:40:00,850: INFO/ForkPoolWorker-8] Exception:
superagi-celery-1 | 2023-06-27 16:40:00 UTC - Super AGI - INFO - [/app/superagi/llms/openai.py:80] - You exceeded your current quota, please check your plan and billing details.
superagi-celery-1 | [2023-06-27 16:40:00,850: INFO/ForkPoolWorker-8] You exceeded your current quota, please check your plan and billing details.
superagi-celery-1 | [2023-06-27 16:40:00,876: ERROR/ForkPoolWorker-8] Task execute_agent[4cf2fba1-afee-4c0c-8966-1d313015f452] raised unexpected: KeyError('content')
superagi-celery-1 | Traceback (most recent call last):
superagi-celery-1 | File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 451, in trace_task
superagi-celery-1 | R = retval = fun(*args, **kwargs)
superagi-celery-1 | File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 734, in __protected_call__
superagi-celery-1 | return self.run(*args, **kwargs)
superagi-celery-1 | File "/usr/local/lib/python3.9/site-packages/celery/app/autoretry.py", line 54, in run
superagi-celery-1 | ret = task.retry(exc=exc, **retry_kwargs)
superagi-celery-1 | File "/usr/local/lib/python3.9/site-packages/celery/app/task.py", line 717, in retry
superagi-celery-1 | raise_with_context(exc)
superagi-celery-1 | File "/usr/local/lib/python3.9/site-packages/celery/app/autoretry.py", line 34, in run
superagi-celery-1 | return task._orig_run(*args, **kwargs)
superagi-celery-1 | File "/app/superagi/worker.py", line 19, in execute_agent
superagi-celery-1 | AgentExecutor().execute_next_action(agent_execution_id=agent_execution_id)
superagi-celery-1 | File "/app/superagi/jobs/agent_executor.py", line 203, in execute_next_action
superagi-celery-1 | response = spawned_agent.execute(agent_workflow_step)
superagi-celery-1 | File "/app/superagi/agent/super_agi.py", line 168, in execute
superagi-celery-1 | if response['content'] is None:
superagi-celery-1 | KeyError: 'content'
Not sure if it helps since SuperAGI runs in Docker but I'm running on a Windows machine. I'm on Docker 20.10.17 build 100c701.
https://github.com/TransformerOptimus/SuperAGI/pull/628 I think This PR will resolve your issue
I had this same problem. I deleted the docker, installed it again and it started working. The first install had the error where it was just thinking and thinking and I check the logs and it was just looping and looping.
OK, I also got paid again and I got access to Google Maker Suite to test out my Palm API too. I'll probably backup my original config, delete my docker containers, and start the installation again.
From: sblaque @.> Sent: Saturday, August 26, 2023 12:09 PM To: TransformerOptimus/SuperAGI @.> Cc: Subscribed @.***> Subject: Re: [TransformerOptimus/SuperAGI] OpenAI API Key encryption / decryption causing API key issues (Issue #272)
I had this same problem. I deleted the docker, installed it again and it started working. The first install had the error where it was just thinking and thinking and I check the logs and it was just looping and looping.
— Reply to this email directly, view it on GitHubhttps://github.com/TransformerOptimus/SuperAGI/issues/272#issuecomment-1694412379, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AADNUL6I2HIPPCLCEDUVW5TXXIUTPANCNFSM6AAAAAAY7ZW45Y. You are receiving this because you are subscribed to this thread.Message ID: @.***>