[英]What is suffix and prefix prompt in openai Codex?
I have been trying to understand what is the suffix prompt in addition to the prefix prompt in Codex.除了 Codex 中的前缀提示之外,我一直在尝试了解后缀提示是什么。
They have provided an example他们提供了一个例子
def get_largest_prime_factor(n):
if n < 2:
return False
def is_prime(n): > for i in range(2, n): > if n % i == 0: > return False > return True > largest = 1
for j in range(2, n + 1):
if n % j == 0 and is_prime(j):
return largest
From this example it is not clear to me how to create a suffix prompt?从这个例子中我不清楚如何创建后缀提示?
What I understand is suffix prompt is for code insert model.我理解的是后缀提示是代码插入 model。 My use case is also
insert
mode ie, code needs to be updated in the middle of a code snippet.我的用例也是
insert
模式,即需要在代码片段中间更新代码。
Can anyone please provide a snippet showing how I can use the suffix prompt so that Codex works in the insert mode?谁能提供一个片段,显示我如何使用后缀提示,以便 Codex 在插入模式下工作?
This python example worked for me.这个 python 示例对我有用。
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
# Example per https://beta.openai.com/docs/guides/completion/inserting-text
prompt="I went to college at Boston University. After getting my degree, I decided to make a change. A big change!"
suffix="Now, I can’t get enough of the Pacific Ocean!"
# Use "suffix" parameter documented in
# https://beta.openai.com/docs/api-reference/completions/create#completions/create-suffix
response = openai.Completion.create(
model="text-davinci-002",
prompt=prompt,
suffix=suffix,
temperature=0.6
)
# Print completion
print( response["choices"][0]["text"] )
# Typical output
# "I moved to California! I love the weather and all the new adventures it brings"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.