欢迎光临散文网 会员登陆 & 注册

在python中调用open ai以用于...

2023-01-03 18:49 作者:lymangos  | 我要投稿

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)


*或封装进模块


在python中调用open ai以用于...的评论 (共 条)

分享到微博请遵守国家法律