manga-image-translator
manga-image-translator copied to clipboard
gpt使用不了
报错APIConnectionError: Error communicating with OpenAI
使用的第三方站 后缀v1加不加都试过了
什么第三方站,要翻墙吗
我也遇到了同样的问题,之前是可以正常使用的,今天pull之后突然用不了gpt了,我在gpt4里插了个桩,能看到地址和key都是对的
这个第三方api我在其他的gpt客户端都可以不翻墙正常使用,但是在这边翻译图片时现在会报错
将 manga_translator/translators/chatgpt.py 文件中的请求方式换为 requests 包去请求,下面代码供参考。
def requestOpenAi(data, headers, token_count, token_count_last): print("----------requestOpenAi") try: response = requests.post('https://api.openai.com/v1/chat/completions', json=data, headers=headers, proxies={ "http":"http://%s" % LOCAL_PEOXY, "https":"http://%s" % LOCAL_PEOXY, }) except requests.exceptions.RequestException as e: print(f"请求错误: {e}")
result = response.json()
token_count += result['usage']['total_tokens']
token_count_last = result['usage']['total_tokens']
for choice in result['choices']:
if 'text' in choice:
return choice['text']
# If no response with text is found, return the first response's content (which may be empty)
return result['choices'][0]['message']['content'], token_count, token_count_last