OpenAI API로 배우는 프롬프트 엔지니어링
Fouad Trad
Machine Learning Engineer
원하는 응답을 얻기 위해 LLM에 제공하는 프롬프트 또는 지시를 설계하는 것





모든 메시지에는 세 가지 역할 중 하나가 있습니다

모든 메시지에는 세 가지 역할 중 하나가 있습니다

모든 메시지에는 세 가지 역할 중 하나가 있습니다

모든 메시지에는 세 가지 역할 중 하나가 있습니다

모든 메시지에는 세 가지 역할 중 하나가 있습니다

모든 메시지에는 세 가지 역할 중 하나가 있습니다


temperature: 응답의 무작위성 조절
temperature: 응답의 무작위성 조절max_tokens: 응답 길이 조절prompt = "What is prompt engineering?"client = OpenAI(api_key="api_key")response = client.chat.completions.create(model = "gpt-4o-mini",messages = [{"role": "user", "content": prompt}],temperature = 0 )print(response.choices[0].message.content)
Prompt engineering refers to the process of designing and refining prompts or
instructions given to a language model like ChatGPT in order to elicit desired
responses or behaviors. It involves formulating specific guidelines or hints to
guide the model's output towards a desired outcome.
def get_response(prompt):response = client.chat.completions.create( model = "gpt-4o-mini", messages = [{"role": "user", "content": prompt}], temperature = 0 )return response.choices[0].message.content
사용법
response = get_response("What is prompt engineering?")
print(response)
Prompt engineering refers to the process of designing and refining prompts or instructions given to a language model
like ChatGPT in order to elicit desired responses or behaviors. It involves formulating specific guidelines or hints
to guide the model's output towards a desired outcome.
prompt = "What is prompt engineering? Explain it in terms that can be understood
by a 5-year-old"
response = get_response(prompt)
print(response)
Imagine you have a very smart friend who can understand and answer lots of
questions. But sometimes, they might not understand exactly what you want or give
the wrong answer. So, prompt engineering is like giving your friend really clear
instructions or hints to help them give you the best answer possible.
OpenAI API로 배우는 프롬프트 엔지니어링