0

it's so odd. when i call the funciton to translate the contents to Traditional Chinese openai gives me a bunch of unicodes, that i dont even understand

BUT, if i use playground on openai website to translate to Traditional Chinese, it works fine.

title = "U.S. Treasury Says DeFi Threatens National Security; MacOS Mystery Over Hidden Bitcoin White Paper"

completion = openai.ChatCompletion.create(
model="gpt-4",
messages=[
    {"role": "system", "content": "you are a blockchain expert and financial trader"},
    {"role": "user", "content": f"translate this content {n} to Traditional Chinese"},
]
)
result = completion.choices[0].message
print(result)

when i ask openai to translate to French or Swedish or others languange it works perfectly fine!

by the way, it works with GPT-3-turbo, but not GPT-3.5 and 4

have no idea what's wrong, please help

JacobH
  • 11
  • 1
  • 4
  • How do you test this? Maybe problem is just printing in your console (encoding/code-page issues)? Can you show example output? – Marek R Apr 11 '23 at 13:31
  • output : "content": "\u8fd9\u573a\"\u5bf9\u52a0\u5bc6\u7684\u6218\u4e89\"\u662f\u4e00\u573a\u72ec\u7279\u7684\u7f8e\u56fd\u6218\u4e89\u5417\uff1f" – JacobH Apr 11 '23 at 13:33
  • I pasted that to my python cosole `a = "\u8fd9\u573a\"\u5bf9\u52a0\u5bc6\u7684\u6218\u4e89\"\u662f\u4e00\u573a\u72ec\u7279\u7684\u7f8e\u56fd\u6218\u4e89\u5417\uff1f"` and printed `a` outcome is correct: `这场"对加密的战争"是一场独特的美国战争吗?`. So I'm right: everything works, your console is badly configured or you are viewing this data in bad way. – Marek R Apr 11 '23 at 13:37
  • do you mean i need to do some settings on console so that can print the Chinese words? thank you for your reply – JacobH Apr 11 '23 at 13:39
  • Looks like encoding on your output device is unable to show those characters so fallback kicks in (escape sequence for Unicode). So API works problem is presenting data. Try run this in python console not from system console. – Marek R Apr 11 '23 at 13:43
  • :( same, i always run with python console, and that's even weird if I use "text-davinci-003" model, the output print Chinese words perfectly – JacobH Apr 11 '23 at 13:54
  • Try this: https://stackoverflow.com/a/38401636/1387438 – Marek R Apr 11 '23 at 14:00

0 Answers0