chat-langchain icon indicating copy to clipboard operation
chat-langchain copied to clipboard

For somebody who need to use proxy to access, you can try this

Open imchao9 opened this issue 1 year ago • 10 comments

1、add below code:

import openai
openai.proxy = {
            "http": "http://127.0.0.1:7890",
            "https": "http://127.0.0.1:7890"
        }

2、change openai.py file:

max_reties = 6
stop=stop_after_attempt(max_reties),

imchao9 avatar Mar 12 '23 15:03 imchao9

where is openai.py file

Skyexu avatar Mar 22 '23 17:03 Skyexu

where is openai.py file

I added a proxy to the header of the main.py file and it is working.

xhongc avatar Mar 27 '23 07:03 xhongc

where is openai.py file

I added a proxy to the header of the main.py file and it is working.

great! it really works fine with me. thank you!

jackbai233 avatar Apr 11 '23 02:04 jackbai233

thanks, it solved my problem

lance2016 avatar Apr 18 '23 02:04 lance2016

where is openai.py file

If using openai.proxy to set up a proxy does not work, you can try setting up a network proxy by setting environment variables using the following code:

import os
os.environ["http_proxy"] = "http://127.0.0.1:7890"
os.environ["https_proxy"] = "http://127.0.0.1:7890"

In this code, the port number is the port number of the proxy software, for example, 7890 for Clash.

Skyexu avatar Apr 18 '23 06:04 Skyexu

Hi is there a way to add proxy for javascript?

gavinnwang avatar Jun 15 '23 14:06 gavinnwang

It's also viable to setup OPENAI_PROXY=http://IP:PORT env variable

CDT avatar Nov 01 '23 01:11 CDT

It's also viable to setup OPENAI_PROXY=http://IP:PORT env variable

It works! Thank you

Ender-Wiggin2019 avatar Nov 08 '23 09:11 Ender-Wiggin2019

Thank you, finally got through

zhangleinice avatar Nov 12 '23 05:11 zhangleinice

where is openai.py file

If using openai.proxy to set up a proxy does not work, you can try setting up a network proxy by setting environment variables using the following code:

import os
os.environ["http_proxy"] = "http://127.0.0.1:7890"
os.environ["https_proxy"] = "http://127.0.0.1:7890"

In this code, the port number is the port number of the proxy software, for example, 7890 for Clash.

Thank you!It works well.

wyf23187 avatar Jan 18 '24 09:01 wyf23187