在python中调用open ai以用于...
ahk源码:
^d::
Send, import openai^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, prompt=input()^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, openai.api_key = "填入api"^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, model_engine = "text-davinci-002"^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, completion = openai.Completion.create(engine=model_engine, prompt=prompt, max_tokens=1024, n=1,stop=None,temperature=0.5)^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, response = completion.choices[0].text^M
Send, {Enter down}
Sleep, 100
Send, {Enter up}
Send, print(response)^M
return
python源码:
openai.api_key = "填入api"
model_engine = "text-davinci-002"
prompt = input()
completion = openai.Completion.create(engine=model_engine, prompt=prompt, max_tokens=1024, n=1,stop=None,temperature=0.5)
response = completion.choices[0].text
print(response)
*或封装进模块