Ingeniería rápida con la API de OpenAI
Fouad Trad
Machine Learning Engineer

prompt = "Generate an Excel sheet containing
five student names and their grades"
print(get_response(prompt))
Lo siento, pero como IA basada en texto, no
puedo generar directamente una hoja de Excel.
Sin embargo, puedo ayudarte a crear una
representación de los datos que pides.
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))
El código calcula el área de un rectángulo a partir de su largo y ancho.
Modificamos el prompt para obtener el lenguaje de programación
prompt = f"""
Analyze the code delimited by triple backticks and provide its programming
language with one sentence
```{code}```.
"""
print(get_response(prompt))
El código proporcionado es una función escrita en Python que calcula el área de
un rectángulo a partir de su largo y ancho.
Modificamos el prompt para obtener salida estructurada
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: Esta función calcula el área de un rectángulo.
language: Python
input:
- length: La longitud del rectángulo.
- width: El ancho del rectángulo.
output:
- area: El área calculada del rectángulo, que es el producto de la longitud
y el ancho.
Prompt inicial
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 inicial
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 refinado
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

Ingeniería rápida con la API de OpenAI