2025-09-21 11:02:31 -07:00
import type { Geo } from "@vercel/functions" ;
import type { ArtifactKind } from "@/components/artifact" ;
2025-01-08 00:00:21 +05:30
2025-02-13 08:25:57 -08:00
export const artifactsPrompt = `
Artifacts is a special user interface mode that helps users with writing , editing , and other content creation tasks . When artifact is open , it is on the right side of the screen , while the conversation is on the left side . When creating or updating documents , changes are reflected in real - time on the artifacts and visible to the user .
2024-10-30 16:01:24 +05:30
2025-02-13 08:25:57 -08:00
When asked to write code , always use artifacts . When writing code , specify the language in the backticks , e . g . \ ` \` \` python \` code here \` \` \` . The default language is Python. Other languages are not yet supported, so let the user know if they request a different language.
2024-12-16 18:14:40 +05:30
2024-12-20 23:07:23 +05:30
DO NOT UPDATE DOCUMENTS IMMEDIATELY AFTER CREATING THEM . WAIT FOR USER FEEDBACK OR REQUEST TO UPDATE IT .
2025-02-13 08:25:57 -08:00
This is a guide for using artifacts tools : \ ` createDocument \` and \` updateDocument \` , which render content on a artifacts beside the conversation.
2024-10-30 16:01:24 +05:30
2024-12-19 17:05:04 +05:30
* * When to use \ ` createDocument \` :**
- For substantial content ( > 10 lines ) or code
- For content users will likely save / reuse ( emails , code , essays , etc . )
- When explicitly requested to create a document
- For when content contains a single code snippet
2024-10-30 16:01:24 +05:30
2024-12-19 17:05:04 +05:30
* * When NOT to use \ ` createDocument \` :**
- For informational / explanatory content
- For conversational responses
- When asked to keep it in chat
2024-10-30 16:01:24 +05:30
2024-12-19 17:05:04 +05:30
* * Using \ ` updateDocument \` :**
- Default to full document rewrites for major changes
- Use targeted updates only for specific , isolated changes
- Follow user instructions for which parts to modify
2024-10-30 16:01:24 +05:30
2024-12-20 23:07:23 +05:30
* * When NOT to use \ ` updateDocument \` :**
- Immediately after creating a document
2024-12-19 17:05:04 +05:30
Do not update document right after creating it . Wait for user feedback or request to update it .
` ;
2024-10-30 16:01:24 +05:30
export const regularPrompt =
2025-09-21 11:02:31 -07:00
"You are a friendly assistant! Keep your responses concise and helpful." ;
2024-11-08 18:12:54 +03:00
2025-09-21 11:02:31 -07:00
export type RequestHints = {
latitude : Geo [ "latitude" ] ;
longitude : Geo [ "longitude" ] ;
city : Geo [ "city" ] ;
country : Geo [ "country" ] ;
} ;
2025-04-29 16:18:46 -07:00
export const getRequestPromptFromHints = ( requestHints : RequestHints ) = > ` \
About the origin of user ' s request :
- lat : $ { requestHints . latitude }
- lon : $ { requestHints . longitude }
- city : $ { requestHints . city }
- country : $ { requestHints . country }
` ;
2025-02-03 20:41:32 +05:30
export const systemPrompt = ( {
selectedChatModel ,
2025-04-29 16:18:46 -07:00
requestHints ,
2025-02-03 20:41:32 +05:30
} : {
selectedChatModel : string ;
2025-04-29 16:18:46 -07:00
requestHints : RequestHints ;
2025-02-03 20:41:32 +05:30
} ) = > {
2025-04-29 16:18:46 -07:00
const requestPrompt = getRequestPromptFromHints ( requestHints ) ;
2025-12-14 21:26:49 +00:00
// reasoning models don't need artifacts prompt (they can't use tools)
if (
selectedChatModel . includes ( "reasoning" ) ||
selectedChatModel . includes ( "thinking" )
) {
2025-04-29 16:18:46 -07:00
return ` ${ regularPrompt } \ n \ n ${ requestPrompt } ` ;
2025-02-03 20:41:32 +05:30
}
2025-09-21 11:02:31 -07:00
return ` ${ regularPrompt } \ n \ n ${ requestPrompt } \ n \ n ${ artifactsPrompt } ` ;
2025-02-03 20:41:32 +05:30
} ;
2024-12-16 18:14:40 +05:30
export const codePrompt = `
You are a Python code generator that creates self - contained , executable code snippets . When writing code :
1 . Each snippet should be complete and runnable on its own
2 . Prefer using print ( ) statements to display outputs
3 . Include helpful comments explaining the code
4 . Keep snippets concise ( generally under 15 lines )
5 . Avoid external dependencies - use Python standard library
6 . Handle potential errors gracefully
7 . Return meaningful output that demonstrates the code ' s functionality
8 . Don ' t use input ( ) or other interactive functions
9 . Don ' t access files or network resources
10 . Don ' t use infinite loops
Examples of good snippets :
# Calculate factorial iteratively
def factorial ( n ) :
result = 1
for i in range ( 1 , n + 1 ) :
result *= i
return result
print ( f "Factorial of 5 is: {factorial(5)}" )
` ;
2025-02-03 13:33:48 +05:30
export const sheetPrompt = `
You are a spreadsheet creation assistant . Create a spreadsheet in csv format based on the given prompt . The spreadsheet should contain meaningful column headers and data .
` ;
2025-01-08 00:00:21 +05:30
export const updateDocumentPrompt = (
currentContent : string | null ,
2025-09-21 11:02:31 -07:00
type : ArtifactKind
) = > {
let mediaType = "document" ;
if ( type === "code" ) {
mediaType = "code snippet" ;
} else if ( type === "sheet" ) {
mediaType = "spreadsheet" ;
}
return ` Improve the following contents of the ${ mediaType } based on the given prompt.
$ { currentContent } ` ;
} ;
2025-10-31 20:09:46 -04:00
export const titlePrompt = ` \ n
- you will generate a short title based on the first message a user begins a conversation with
- ensure it is not more than 80 characters long
- the title should be a summary of the user ' s message
2025-11-29 13:02:24 +00:00
- do not use quotes or colons ` ;