MCPcopy Index your code
hub / github.com/TanStack/ai / generateId

Function generateId

packages/ai-utils/src/id.ts:1–9  ·  view source on GitHub ↗
(prefix: string)

Source from the content-addressed store, hash-verified

1export function generateId(prefix: string): string {
2 const timestamp = Date.now()
3 // Drop the "0." prefix from the base36 float (2 chars), keeping the full
4 // random portion (~9+ chars of entropy). Previously used `.substring(7)`
5 // which left only ~4 random chars — see the regression test in ai-fal's
6 // utils.
7 const randomPart = Math.random().toString(36).substring(2)
8 return `${prefix}-${timestamp}-${randomPart}`
9}

Callers 15

chatStreamFunction · 0.90
structuredOutputStreamFunction · 0.90
processStreamChunksFunction · 0.90
chatStreamFunction · 0.90
structuredOutputStreamFunction · 0.90
handleContentPartFunction · 0.90
processStreamChunksFunction · 0.90
generateImagesMethod · 0.90
editImagesMethod · 0.90
transcribeMethod · 0.90
generateImagesMethod · 0.90
editImagesMethod · 0.90

Calls 2

nowMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected