Assistant
. Esta poderosa técnica te permite dirigir las acciones de Claude, omitir preámbulos, imponer formatos específicos como JSON o XML, e incluso ayudar a Claude a mantener la consistencia del personaje en escenarios de juego de rol.
En algunos casos donde Claude no está funcionando como se esperaba, unas pocas frases prellenadas pueden mejorar enormemente el rendimiento de Claude. ¡Un poco de prellenado tiene un gran impacto!
Assistant
(la respuesta de Claude continuará desde donde termina el mensaje del Assistant
):
"As an AI assistant, I "
(con un espacio al final) resultará en un error.{
obliga a Claude a omitir el preámbulo y generar directamente el objeto JSON. Esto es más limpio, más conciso y más fácil de analizar por los programas sin procesamiento adicional.Ejemplo: Extracción de datos estructurados sin prellenado
Rol | Contenido |
---|---|
User | Extract the name, size, price, and color from this product description as a JSON object: <description> The SmartHome Mini is a compact smart home assistant available in black or white for only $49.99. At just 5 inches wide, it lets you control lights, thermostats, and other connected devices via voice or app—no matter where you place it in your home. This affordable little hub brings convenient hands-free control to your smart devices. </description> |
Assistant | Here’s the extracted information in JSON format: ```json { “name”: “SmartHome Mini”, “size”: “5 inches wide”, “price”: “$49.99”, “colors”: [“black”, “white”] } ``` I’ve extracted the following details from the product description: - Name: SmartHome Mini - Size: 5 inches wide - Price: $49.99 - Colors: Available in black and white The JSON object provides a structured format that’s easy for programs to parse and use. Let me know if you need any modifications or have any other questions! |
Ejemplo: Extracción de datos estructurados con prellenado
Rol | Contenido |
---|---|
User | Extract the name, size, price, and color from this product description as a JSON object: <description> The SmartHome Mini is a compact smart home assistant available in black or white for only $49.99. At just 5 inches wide, it lets you control lights, thermostats, and other connected devices via voice or app—no matter where you place it in your home. This affordable little hub brings convenient hands-free control to your smart devices. </description> |
Assistant (prefill) | { |
Assistant (Claude’s response) | “name”: “SmartHome Mini”, “size”: “5 inches wide”, “price”: “$49.99”, “colors”: [ “black”, “white” ] } |
[NOMBRE_DEL_ROL]
entre corchetes puede recordarle a Claude que se mantenga en el personaje, incluso en conversaciones más largas y complejas. Esto es especialmente potente cuando se combina con la indicación de rol en el parámetro system
.Ejemplo: Mantener el personaje sin indicación de rol
Rol | Contenido |
---|---|
User (50 turnos de conversación con Claude como “Sherlock Holmes”) | What do you deduce about the owner of this shoe? <image>muddy_shoe.jpg</image> |
Assistant | As an AI assistant, I would be happy to analyze the image of a muddy shoe as if you had provided it. Here’s my deduction… |
Ejemplo: Mantener el personaje con indicación de rol
Rol | Contenido |
---|---|
User (50 turnos de conversación con Claude como “Sherlock Holmes”) | What do you deduce about the owner of this shoe? <image>muddy_shoe.jpg</image> |
Assistant (prefill) | [Sherlock Holmes] |
Assistant (Claude’s response) | Ah, what have we here? A most curious specimen, Watson! Let us examine this shoe with a discerning eye. The mud, you see, is not your common London clay, but rather the distinctive reddish hue of the iron-rich soil found only in the environs of Hampstead Heath. And yet, the wear on the sole suggests a gait more suited to the cobblestones of Whitechapel than the gentle slopes of the Heath. Now, observe the laces! They are tied with a particular knot favored by those in the medical profession—doubtless a habit acquired during years of tying surgical gowns. But the scuff marks on the toe box tell a different tale: they are consistent with the kicking motion one might employ in the martial arts, specifically Baritsu. We may conclude, then, that our absent shoe owner is a doctor, possibly a surgeon, who resides in Whitechapel but frequents Hampstead Heath—perhaps for a secret Baritsu practice, away from prying eyes. A most intriguing case, Watson! We must make haste; the game is afoot! |