Prompt Engineering dengan OpenAI API
Fouad Trad
Machine Learning Engineer

prompt = "Generate an Excel sheet containing
five student names and their grades"
print(get_response(prompt))
Maaf, sebagai AI berbasis teks, saya
tidak dapat langsung menyediakan lembar Excel.
Namun, saya dapat membantu membuat contoh
representasi data yang Anda minta.
prompt = "Generate a table that I can copy
to Excel, containing five student names and
their grades"
print(get_response(prompt))
| Student Name | Grade |
|--------------|-------|
| Student 1 | 90 |
| Student 2 | 85 |
| Student 3 | 95 |
| Student 4 | 88 |
| Student 5 | 92 |
code = '''
def calculate_rectangle_area(length, width):
area = length * width
return area
'''

prompt = f"""
Analyze the code delimited by triple backticks with one sentence
```{code}```.
"""
print(get_response(prompt))
Kodenya menghitung luas persegi panjang berdasarkan panjang dan lebar.
Kita ubah prompt untuk mendapatkan bahasa pemrograman
prompt = f"""
Analyze the code delimited by triple backticks and provide its programming
language with one sentence
```{code}```.
"""
print(get_response(prompt))
Kode yang diberikan adalah fungsi Python yang menghitung luas persegi panjang berdasarkan panjang dan lebarnya.
Kita ubah prompt untuk keluaran terstruktur
prompt = f"""
For the function delimited by triple backticks, provide in a structured format
the following:
- description: one sentence short description
- language: the programming language used
- input: the inputs to the function
- output: the output returned by the function
```{code}```.
"""
print(get_response(prompt))
description: Fungsi ini menghitung luas persegi panjang.
language: Python
input:
- length: Panjang persegi panjang.
- width: Lebar persegi panjang.
output:
- area: Luas persegi panjang, yaitu hasil kali panjang dan lebar.
Prompt awal
prompt = """
Clear skies and a gentle breeze. -> Sunny
Heavy rain and thunderstorms expected. -> Rainy
Fresh snowfall with freezing temperatures. ->
"""
print(get_response(prompt))
Snowy
Prompt awal
prompt = """
Clear skies and a gentle breeze. -> Sunny
Heavy rain and thunderstorms expected. -> Rainy
The wind of change brought a refreshing breeze to the company's operations. ->
"""
print(get_response(prompt))
Windy
Prompt yang disempurnakan
prompt = """
Clear skies and a gentle breeze. -> Sunny
Heavy rain and thunderstorms expected. -> Rainy
The political climate in the country was stormy -> Unknown
The wind of change brought a refreshing breeze to the company's operations. ->
"""
print(get_response(prompt))
Unknown

Prompt Engineering dengan OpenAI API