1 篇文章带有标签 “ChatGPT-API”

Building Systems with the ChatGPT API

Building Systems with the ChatGPT API

使用 ChatGPT API 构建系统

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0,
    )
    return response.choices[0].message["content"]
response = get_completion("What is the capital of France?")
print(response)
The capital of France is Paris.
response = get_completion("法国的首都是什么?")
print(response)
法国的首都是巴黎。