import openai
import pyperclip
import time
openai.api_key = "redacted"
prev_clipboard_text = pyperclip.paste()
while True:
clipboard_text = pyperclip.paste()
if clipboard_text != prev_clipboard_text:
prompt = f"Translate the following {source_lang} text into {target_lang}: '{clipboard_text}'"
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "translate any japanese text to english"},
{"role": "user", "content": "{clipboard_text}"}
]
)
output_text = response['choices'][0]['message']['content']
filename = "translation.txt"
with open(filename, "w", encoding="utf-8") as f:
f.write(clipboard_text + "=" + output_text + "\n")
print("the translation is =" + clipboard_text + "=" + output_text + "\n")
prev_clipboard_text = clipboard_text
time.sleep(0.5)
with this code i am translating japanese text from the clipboard to english using the openai api, i am just stuck on how to give the gpt-3.5-turbo the prompt to use the variable clipboard_text as the japanese text that it needs to translate, if i do copy some text it will tell me that it has not received any japanese text to translate