Poetry Writing Example
This example demonstrates how to use an AI model to write poetry.
Task
Write a poem based on given requirements and style preferences.
Prompt
Please write a poem according to the following requirements:
1. Style: [specific poetic style/form]
2. Theme: [user-provided theme]
3. Writing requirements:
- Follow the specified poetic form
- Use vivid imagery and metaphors
- Maintain consistent rhythm and meter
- Create emotional resonance
Example
User Input
Write a poem in the style of classical Chinese poetry about an airplane.
Assistant Response
Silver wings soar through azure heights,
Breaking clouds, ascending to new sights.
Autumn geese glide on winds below,
While I gaze down from towers of snow.
The vast horizon meets the sea,
Where sunset flames dance wild and free.
Earth's grandeur shrinks beneath my view,
As spirit soars in boundless blue.
Analysis: This poem captures the majesty of flight through classical imagery and natural elements. It weaves together traditional poetic elements with modern technology, creating a bridge between ancient and contemporary themes. The imagery of silver wings, clouds, and geese creates a vivid picture of flight, while maintaining the contemplative spirit common in classical poetry.
Code Implementation
from openai import OpenAI
client = OpenAI(
base_url="https://api.deepseek.com/",
api_key="<YOUR_API_KEY>"
)
completion = client.chat.completions.create(
model="deepseek-chat",
messages=[
{
"role": "user",
"content": "Write a classical-style poem about an airplane..."
}
]
)
print(completion.choices[0].message.content)