reworkd / AgentGPT

🤖 Assemble, configure, and deploy autonomous AI Agents in your browser.
https://agentgpt.reworkd.ai
GNU General Public License v3.0
31.96k stars 9.26k forks source link

My OpenAI API not work after installation. #609

Closed p6002 closed 1 year ago

p6002 commented 1 year ago

Discussed in https://github.com/reworkd/AgentGPT/discussions/605

Originally posted by **p6002** May 26, 2023 I cloned the github repo, ran `./setup.sh --docker` API during installation shows Valid. When I log in via `localhost:3000` and run the task, it shows: ERROR when connecting to the OpenAI API key. Please check the API key or try later. I checked and in next/.env there is a valid API on OpenAI. What am I doing wrong? image image image image
asim-shrestha commented 1 year ago

Hey, can you retry running the ./setup.sh script? We've recently updated it

p6002 commented 1 year ago

Previously I used ./setup.sh --docker, now after using ./setup.sh it shows:

image

Using ./setup.sh --docker, the container run, but on the page, agent won't start up showing the same error as before:

ERROR when connecting to the OpenAI API key. Please check the API key or try later.

asim-shrestha commented 1 year ago

So you need to first fetch and pull the latest changes from master. To confirm this, make sure there is a cli directory.

Next, the error message shows you have an outdated version of node installed. If you have nvm

nvm install 18
nvm use 18

From there, re-run setup.sh it will ask you how you're running it (docker-compose, docker, etc) and ask you to provide a set of API keys for the different services we utilize

p6002 commented 1 year ago

I managed (after several hours) to get the new version working. (It was necessary to manually add the IP address of the server instead of "localhost" in the .env files.

However, it did not change anything, and the error with the API on the website still appears.

The API is entered correctly during installation (serper also), the same OpenAI API works in other tools without any problem.

This output generates the terminal while the application is running (after ./setup.sh): image

yiyunfei-001 commented 1 year ago

i also meet the problem,dose someone have solve the problem

awtkns commented 1 year ago

I managed (after several hours) to get the new version working. (It was necessary to manually add the IP address of the server instead of "localhost" in the .env files.

However, it did not change anything, and the error with the API on the website still appears.

The API is entered correctly during installation (serper also), the same OpenAI API works in other tools without any problem.

This output generates the terminal while the application is running (after ./setup.sh): image

@p6002 given the error message you've provided it seems you may have something else running on port 8000? Could you be running this or another project locally?

bitsnaps commented 1 year ago

Trying different ways (with setup.sh or compile everyting manually npm, poetry...), I'm still getting ERROR accessing OpenAI's API. Please check your API key or try again later, the api key is working locally.

JumpyWizard404 commented 1 year ago

Same issue when using the container version of the deployment

JumpyWizard404 commented 1 year ago

Managed to get it to work: this is for the docker deployment one where i noticed that it was not properly formating the request as the environment variable was set to REWORKD_PLATFORM_OPENAI_API_BASE="https://api.openai.com/v1" the docker logs were showing that the URL it was sending requests to ended up being formated as "https://api.openai.com/v1"/chat/completions and were not communicating After updating the environment variable to REWORKD_PLATFORM_OPENAI_API_BASE=https://api.openai.com/v1 it started properly communicating to the API, also note i used the version 5.0-beta from https://github.com/reworkd/AgentGPT/releases/tag/v.0.5.0-beta

GGGyanice commented 1 year ago

I guess it is connected to the openai has a problem, Because I rewrote create_model function to use AzureChatOpenAI instead of ChatOpenAI, it works...but my openai key can be used in other code

p6002 commented 1 year ago

@awtkns given the error message you've provided it seems you may have something else running on port 8000? Could you be running this or another project locally?

I only have Portainer Agent on port 9001:

image


This is the result of the ./setup.sh command: image

My docker-compose file: https://pastebin.com/DNWMN9dT

Env file: https://pastebin.com/mKgCR6Ud

I think I tried every combination of URLs, currently it looks like the above.


It would be useful to have an example of a filled .env file and docker-compose, for example, for the local server address 192.168.1.100 I could easily convert it to my own data.

Currently, I have no idea what the difference is between the env entries:

PLATFORM_URL=
NEXTAUTH_URL=
REWORKD_PLATFORM_FRONTEND_URL=

Default entries http://localhost:8000/ does not work, in addition one of them contains as an example: http://host.docker.internal:8000

francoborgia commented 1 year ago

same problem with key if anyone managed to fix

Screenshot 2023-05-31 alle 17 51 36
p6002 commented 1 year ago

After completely deleting and cloning the new repo (0.6.0), I was able to get the agent up and running. The only changes I made in next/.env instead of localhost I entered my server IP address here:

NEXT_PUBLIC_BACKEND_URL=
NEXTAUTH_URL=
REWORKD_PLATFORM_FRONTEND_URL=
MSYXing commented 1 year ago

May I ask how you started it? Don't you have the problem about "blocked by CORS policy"? I also used the 0.6.0 version and completed the relevant changes you mentioned. Here is my problom: I tried running this command (docker-compose -f deploy/docker-compose.yml --project-directory . up --build) and it showed that it was started, but the request (http://localhost:3000/api/agent/start) showed "blocked by CORS policy", and then I added this link(https://cors-anywhere.herokuapp.com/http://localhost:3000/api/agent/start) to fix it, but now 403

p6002 commented 1 year ago

I just cloned the repository, ran ./setup.sh, docker_compose method and pasted the first two api. Setup ends with an error because you have to correct next/.env by typing what I specified in the previous post.