Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for not local installations #15

Closed
antonme opened this issue Mar 9, 2023 · 13 comments
Closed

Support for not local installations #15

antonme opened this issue Mar 9, 2023 · 13 comments

Comments

@antonme
Copy link
Contributor

antonme commented Mar 9, 2023

Hello, I hope this message finds you well. I was exploring the chatgpt-clone project and noticed that it appears to be designed to run on a local machine and only be accessed from there. It would be incredibly beneficial if it were possible to install the project on an external machine as well. I attempted this in my home lab environment, but unfortunately, I was unable to make it work. Thank you for your time and consideration

@danny-avila
Copy link
Owner

Would installing and using docker in your environment not work? I agree remote install would be best, and it’s on my list to attempt a remote deployment. I figured docker is the first step and someone could make it work that way already

@antonme
Copy link
Contributor Author

antonme commented Mar 9, 2023

There's no problem running on local machine, but when I run externally, client still tries to go to "localhost:3080", for example, and it seems that there more than one thing that assumes that everything is on a single machine really.

I am glad that it is in your todo list, that'll be great

@DavesDevFails
Copy link

DavesDevFails commented Mar 9, 2023

You just need to search and replace around 12 occurrences of http://localhost:3080 with http(s)://your-url-here.com

Better still add it as a 'BASE_URL' .env variable

@danny-avila
Copy link
Owner

danny-avila commented Mar 10, 2023

#19 now supports configuring host name, thanks to @wtlyu, would that work for you @antonme ?

this was mistaken as the PR somehow messed up the docker setup. I rolled this back but this is indeed a goal to have a more configurable host/port/proxy setup

@Kristovich
Copy link

I was able to spin up a docker this morning on commit 17a3fb5

I did notice the parsing was a little wonky for the "HOST" env. I used - HOST=0.0.0.0 to get my setup working on my server. Using quotes (e.g. - HOST="0.0.0.0") broke it. Also, I had to comment out - PROXY="" because it was trying to use the empty string as the actual proxy.

Even worked with my traefik reverse proxy too. Worked with both my openai key and my bing cookie.

@danny-avila
Copy link
Owner

I was able to spin up a docker this morning on commit 17a3fb5

I did notice the parsing was a little wonky for the "HOST" env. I used - HOST=0.0.0.0 to get my setup working on my server. Using quotes (e.g. - HOST="0.0.0.0") broke it. Also, I had to comment out - PROXY="" because it was trying to use the empty string as the actual proxy.

Even worked with my traefik reverse proxy too. Worked with both my openai key and my bing cookie.

Thanks so much @Kristovich very useful information. Tagging @wtlyu in case they get to it before me.

@wtlyu
Copy link
Contributor

wtlyu commented Mar 11, 2023

I was able to spin up a docker this morning on commit 17a3fb5

I did notice the parsing was a little wonky for the "HOST" env. I used - HOST=0.0.0.0 to get my setup working on my server. Using quotes (e.g. - HOST="0.0.0.0") broke it. Also, I had to comment out - PROXY="" because it was trying to use the empty string as the actual proxy.

Even worked with my traefik reverse proxy too. Worked with both my openai key and my bing cookie.

Hello sir, I'm working to fix this commit #19 . I have tried - HOST="0.0.0.0" but it works as expected on my local machine. Can you provide more information for me to this problem? I wrote react but new to express.js. Can you write me your test, for example what's your environment, what you want to get and what's the wrong result?

I have tested on - HOST="0.0.0.0" - HOST=0.0.0.0 - HOST= and - HOST="localhost". it works well...

@Kristovich
Copy link

I'm using the docker compose from da62e9a. I built the api and client containers as instructed on the readme.

I also added console.log(`Line 11, host${host}port${port}`); line inside api/server/index.js. When - HOST="0.0.0.0" is set I get:

api_1      |
api_1      | > chatgpt-clone@1.0.0 start
api_1      | > node server/index.js
api_1      |
api_1      | Line 11, host"0.0.0.0"port3080
api_1      | node:events:490
api_1      |       throw er; // Unhandled 'error' event
api_1      |       ^
api_1      |
api_1      | Error: getaddrinfo ENOTFOUND "0.0.0.0"
api_1      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
api_1      | Emitted 'error' event on Server instance at:
api_1      |     at GetAddrInfoReqWrap.doListen [as callback] (node:net:1934:12)
api_1      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:17) {
api_1      |   errno: -3008,
api_1      |   code: 'ENOTFOUND',
api_1      |   syscall: 'getaddrinfo',
api_1      |   hostname: '"0.0.0.0"'
api_1      | }

If - HOST=0.0.0.0 then

api_1      | 
api_1      | > chatgpt-clone@1.0.0 start
api_1      | > node server/index.js
api_1      | 
api_1      | Line 11, host0.0.0.0port3080
api_1      | Server listening at http://0.0.0.0:3080

And while I'm at it: If - PROXY="" is present inside the docker-compose.yml, then the server will work but requests to openai or bing will fail with

api_1      | ask log {
api_1      |   model: 'chatgpt',
api_1      |   id: '[uuid]',
api_1      |   sender: 'User',
api_1      |   text: 'this is a test',
api_1      |   parentMessageId: undefined,
api_1      |   conversationId: undefined,
api_1      |   chatGptLabel: '',
api_1      |   promptPrefix: ''
api_1      | }
api_1      | TypeError [ERR_INVALID_URL]: Invalid URL
api_1      |     at new NodeError (node:internal/errors:399:5)
api_1      |     at new URL (node:internal/url:588:13)
api_1      |     at new ProxyAgent (/api/node_modules/undici/lib/proxy-agent.js:67:25)
api_1      |     at ChatGPTClient.getCompletion (file:///api/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:168:31)
api_1      |     at ChatGPTClient.sendMessage (file:///api/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:297:24)
api_1      |     at async askClient (/api/app/chatgpt-client.js:28:15)
api_1      |     at async /api/server/routes/ask.js:90:23 {
api_1      |   input: '""',
api_1      |   code: 'ERR_INVALID_URL'
api_1      | }

So I had to remove the PROXY env out of the docker-compose file for it to work.

I hope this helps.

@wtlyu
Copy link
Contributor

wtlyu commented Mar 11, 2023

I'm using the docker compose from da62e9a. I built the api and client containers as instructed on the readme.

I also added console.log(`Line 11, host${host}port${port}`); line inside api/server/index.js. When - HOST="0.0.0.0" is set I get:

...

So I had to remove the PROXY env out of the docker-compose file for it to work.

I hope this helps.

That's great! @danny-avila told me last night that this code is incompatible with existing docker compose. I haven't test the docker part after checking on the local environment.

I will double check the docker part. My suspicion now is that it seems that the parsing of the env file is different, in docker.

BTW do you have a local deployment? Can you help me to check if the server work well when -PROXY=? I'm in China and cannot connect to the server directly

@Kristovich
Copy link

I tried making a local environment just now. It wouldn't build for some reason, so I'll probably try again in the morning. But I think you're right. The docker compose parsed the "" whereas it looks like the local env file shows it as null. I'm not familiar with js stuff though.

@wtlyu
Copy link
Contributor

wtlyu commented Mar 11, 2023

I tried making a local environment just now. It wouldn't build for some reason, so I'll probably try again in the morning. But I think you're right. The docker compose parsed the "" whereas it looks like the local env file shows it as null. I'm not familiar with js stuff though.

Thank you! I have experience on docker and just do some research on your test. I will write in another issue #25 since it's not related to this issue.

@antonme
Copy link
Contributor Author

antonme commented Mar 11, 2023

Wow, thank you, @danny-avila and @wtlyu. With the last @wtlyu's PR everything seems to work great for me.
I have to say that I would still prefer not to use Bridge driver and only expose frontend to the open, but these are minor concerns all around. Really great thing you have here!

@danny-avila
Copy link
Owner

Hats off to @wtlyu for the leg work on this! Glad you're enjoying it @antonme !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants