Trying to make Python code that sends text to the gpt-4 and gets back rewrite 400 word text

Hi,
I trying to make Python code that sends text to the gpt-4 and gets back rewritten with an SEO prompt that I am setting, the text is around 400 words, and need to get back 400 words.

the send looks okay but the response does not work and get an error of connecting end, etc. looks like it takes to process it or something like that.
small interaction works the same as the samples/examples.


These are the errors:
WARNING:urllib3 connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘RemoteDisconnected(‘Remote end closed connection without response’)’:

openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api openai com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError('Unable to connect to proxy', RemoteDisconnected('Remote end closed connection without response')))

how do I pass the data and get back the text?
I can send it by JSON and get JSON but is not work too

there is something incorrect with your API function or your network
: (Caused by ProxyError(‘Unable to connect to proxy’, RemoteDisconnected(‘Remote end closed connection without response’)))

You don’t have to answer EVERY post with low-quality responses.

This is not about a GPT, it is API use of assistants.

The first thing to check is if there is even a proxy server being used, being set in the OS, known to be there by the poster with a purpose (or created by malware). Then find out if the Python environment is receiving an incorrect environment varialble somehow. Here’s a post of mine to disable any OS-set proxy setting:

An example of the code that is used for calling the API would be far more helpful in finding out what is going wrong. Select the </> button in the forum’s editor to mark the pasted code as preformatted text when posting.

Apologies for any confusion caused by my previous message. My intention was not to delve into network troubleshooting but rather to guide you towards potential solutions. I understand the importance of clarity, and corrected the oversight of using ‘GPT’ instead of ‘API’ in my explanation, it was a simple miscommunication.

Please know that while I do not respond to every post, I actively monitor discussions and am notified of updates. My responses aim to provide foundational examples to assist people, rather than offering complete code solutions. This approach is designed to encourage learning and exploration while maintaining the integrity of proprietary code.

assuming that is what you mean by low-quality.

https:// github. com/shaiazran/OpenAI-API

her can see my code
123-ai-works. py is my test and work and I am getting a response.
call_to_open-ai. py - is the code that i am trying to pass with big text by JSON etc and get the error:

Sending request to OpenAI…
Error calling OpenAI: Request timed out: HTTPSConnectionPool(host=‘api. openai. com’, port=443): Max retries exceeded with URL : / v1/ chat / completions (Caused by ConnectTimeoutError(<urllib3. connection. HTTPSConnection object at 0x0000022D33395A30>, 'Connection to ‘api. openai. com timed out. (connect timeout=600)’))
Failed to rewrite the product description.

You broke the logic of the NO_PROXY code that I provided by editing it.

It is really frustrating when people say “my code” when they mean “code that an AI wrote which I don’t understand”.

The code you show uses methods obsolete in the latest openai python library.

It uses a wishful unworking mix of placing dictionary keys in square brackets and pydantic model methods.

I would suggest:
Install Python 3.8-3.11
pip uninstall openai (and repeat)
pip install --upgrade openai tiktoken (as administrator if Python is a system install “for everyone”.)

Then read the API documentation, using python examples of chat completions to see how to write “openai.Client()” code.