Getting an error when trying to translate English to Hebrew

There is no problem in Trying to translate the same text to Spanish:

prompt = f"“”
Translate the following English text to Spanish: \


The port has played a significant role in the history of Israel, serving as a gateway for pilgrims, traders, and conquerors. It was the main port for the ancient city of Jaffa, which was a crucial center for trade and commerce in the Mediterranean region.

Jaffa Port has undergone several transformations over the years, from a bustling port to a neglected area, and then to a vibrant cultural and entertainment center. Today, the port is a popular tourist destination, attracting visitors from all over the world.

The port is home to several restaurants, cafes, and shops, offering visitors a unique experience of the local cuisine and culture. The port also hosts various cultural events, including music concerts, art exhibitions, and festivals.

One of the most iconic landmarks in Jaffa Port is the Clock Tower, which was built in 1906 during the Ottoman Empire. The tower served as a lighthouse and a clock for the port, and it is now a symbol of the city's rich history and culture.

In conclusion, Jaffa Port is a must-visit destination for anyone visiting Israel. It offers a unique blend of history, culture, and entertainment, making it a perfect place to explore and experience the rich heritage of Israel.```
"""
response = get_completion(prompt)
print(response)

but the following response is error

prompt = f"""
Translate the following English text to Hebrew: \ 
```Welcome to Jaffa Port, one of the oldest ports in the world and a significant landmark in the history of Israel. Jaffa Port is located in the southern part of Tel Aviv, and it has been a vital trading hub for over 3,000 years.

The port has played a significant role in the history of Israel, serving as a gateway for pilgrims, traders, and conquerors. It was the main port for the ancient city of Jaffa, which was a crucial center for trade and commerce in the Mediterranean region.

Jaffa Port has undergone several transformations over the years, from a bustling port to a neglected area, and then to a vibrant cultural and entertainment center. Today, the port is a popular tourist destination, attracting visitors from all over the world.

The port is home to several restaurants, cafes, and shops, offering visitors a unique experience of the local cuisine and culture. The port also hosts various cultural events, including music concerts, art exhibitions, and festivals.

One of the most iconic landmarks in Jaffa Port is the Clock Tower, which was built in 1906 during the Ottoman Empire. The tower served as a lighthouse and a clock for the port, and it is now a symbol of the city's rich history and culture.

In conclusion, Jaffa Port is a must-visit destination for anyone visiting Israel. It offers a unique blend of history, culture, and entertainment, making it a perfect place to explore and experience the rich heritage of Israel.```
"""
response = get_completion(prompt)
print(response)

this is the error in response:

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:673, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream)
    672     else:
--> 673         data = json.loads(rbody)
    674 except (JSONDecodeError, UnicodeDecodeError) as e:

File /usr/local/lib/python3.9/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    343 if (cls is None and object_hook is None and
    344         parse_int is None and parse_float is None and
    345         parse_constant is None and object_pairs_hook is None and not kw):
--> 346     return _default_decoder.decode(s)
    347 if cls is None:

File /usr/local/lib/python3.9/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335 
    336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

File /usr/local/lib/python3.9/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
    354 except StopIteration as err:
--> 355     raise JSONDecodeError("Expecting value", s, err.value) from None
    356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

APIError                                  Traceback (most recent call last)
Cell In[5], line 15
      1 prompt = f"""
      2 Translate the following English text to Hebrew: \ 
      3 ```Welcome to Jaffa Port, one of the oldest ports in the world and a significant landmark in the history of Israel. Jaffa Port is located in the southern part of Tel Aviv, and it has been a vital trading hub for over 3,000 years.
   (...)
     13 In conclusion, Jaffa Port is a must-visit destination for anyone visiting Israel. It offers a unique blend of history, culture, and entertainment, making it a perfect place to explore and experience the rich heritage of Israel.```
     14 """
---> 15 response = get_completion(prompt)
     16 print(response)

Cell In[2], line 3, in get_completion(prompt, model, temperature)
      1 def get_completion(prompt, model="gpt-3.5-turbo", temperature=0): 
      2     messages = [{"role": "user", "content": prompt}]
----> 3     response = openai.ChatCompletion.create(
      4         model=model,
      5         messages=messages,
      6         temperature=temperature, 
      7     )
      8     return response.choices[0].message["content"]

File /usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py:25, in ChatCompletion.create(cls, *args, **kwargs)
     23 while True:
     24     try:
---> 25         return super().create(*args, **kwargs)
     26     except TryAgain as e:
     27         if timeout is not None and time.time() > start + timeout:

File /usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
    127 @classmethod
    128 def create(
    129     cls,
   (...)
    136     **params,
    137 ):
    138     (
    139         deployment_id,
    140         engine,
   (...)
    150         api_key, api_base, api_type, api_version, organization, **params
    151     )
--> 153     response, _, api_key = requestor.request(
    154         "post",
    155         url,
    156         params=params,
    157         headers=headers,
    158         stream=stream,
    159         request_id=request_id,
    160         request_timeout=request_timeout,
    161     )
    163     if stream:
    164         # must be an iterator
    165         assert not isinstance(response, OpenAIResponse)

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:226, in APIRequestor.request(self, method, url, params, headers, files, stream, request_id, request_timeout)
    205 def request(
    206     self,
    207     method,
   (...)
    214     request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
    215 ) -> Tuple[Union[OpenAIResponse, Iterator[OpenAIResponse]], bool, str]:
    216     result = self.request_raw(
    217         method.lower(),
    218         url,
   (...)
    224         request_timeout=request_timeout,
    225     )
--> 226     resp, got_stream = self._interpret_response(result, stream)
    227     return resp, got_stream, self.api_key

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:620, in APIRequestor._interpret_response(self, result, stream)
    612     return (
    613         self._interpret_response_line(
    614             line, result.status_code, result.headers, stream=True
    615         )
    616         for line in parse_stream(result.iter_lines())
    617     ), True
    618 else:
    619     return (
--> 620         self._interpret_response_line(
    621             result.content.decode("utf-8"),
    622             result.status_code,
    623             result.headers,
    624             stream=False,
    625         ),
    626         False,
    627     )

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:675, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream)
    673         data = json.loads(rbody)
    674 except (JSONDecodeError, UnicodeDecodeError) as e:
--> 675     raise error.APIError(
    676         f"HTTP code {rcode} from API ({rbody})", rbody, rcode, headers=rheaders
    677     ) from e
    678 resp = OpenAIResponse(data, rheaders)
    679 # In the future, we might add a "status" parameter to errors
    680 # to better handle the "error while streaming" case.

APIError: HTTP code 504 from API (<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>
)

how can I fix this?

Sounds like you have tripped into a defect in ChatGPT.

There’s probably nothing you can do about it other than report it to OpenAI.

how do I report? can I open like a ticket/issue somewhere?

Sorry, I have no idea. This forum is operated by DeepLearning.AI, not OpenAI. They’re different companies.

This is something you might want to report to OpenAI for them to improve their model. They do have an incentivized program where you can do this, if you’re interested. Announcing OpenAI’s Bug Bounty Program

1 Like