|
| 1 | +import { useMDXComponents } from 'scenes/onboarding/OnboardingDocsContentWrapper' |
| 2 | + |
| 3 | +const propertyColumnStyle = { minWidth: '150px' } |
| 4 | + |
| 5 | +export const EmbeddingEvent = (): JSX.Element => { |
| 6 | + const { Markdown, dedent } = useMDXComponents() |
| 7 | + |
| 8 | + return ( |
| 9 | + <> |
| 10 | + <Markdown> |
| 11 | + {dedent` |
| 12 | + An embedding is a single call to an embedding model to convert text into a vector representation. |
| 13 | +
|
| 14 | + **Event name**: \`$ai_embedding\` |
| 15 | +
|
| 16 | + ### Core properties |
| 17 | + `} |
| 18 | + </Markdown> |
| 19 | + |
| 20 | + <div className="LemonMarkdown"> |
| 21 | + <table className="my-4"> |
| 22 | + <thead> |
| 23 | + <tr> |
| 24 | + <th style={propertyColumnStyle}>Property</th> |
| 25 | + <th>Description</th> |
| 26 | + </tr> |
| 27 | + </thead> |
| 28 | + <tbody> |
| 29 | + <tr> |
| 30 | + <td style={propertyColumnStyle}> |
| 31 | + <code>$ai_trace_id</code> |
| 32 | + </td> |
| 33 | + <td> |
| 34 | + <p> |
| 35 | + The trace ID (a UUID to group related AI events together). Must contain only letters, numbers, and special characters: <code>-</code>, <code>_</code>, <code>~</code>, <code>.</code>, <code>@</code>, <code>(</code>, <code>)</code>, <code>!</code>, <code>'</code>, <code>:</code>, <code>|</code> |
| 36 | + <br /> |
| 37 | + Example: <code>d9222e05-8708-41b8-98ea-d4a21849e761</code> |
| 38 | + </p> |
| 39 | + </td> |
| 40 | + </tr> |
| 41 | + <tr> |
| 42 | + <td style={propertyColumnStyle}> |
| 43 | + <code>$ai_session_id</code> |
| 44 | + </td> |
| 45 | + <td> |
| 46 | + <p> |
| 47 | + <em>(Optional)</em> Groups related traces together. Use this to organize traces by whatever grouping makes sense for your application (user sessions, workflows, conversations, or other logical boundaries). |
| 48 | + <br /> |
| 49 | + Example: <code>session-abc-123</code>, <code>conv-user-456</code> |
| 50 | + </p> |
| 51 | + </td> |
| 52 | + </tr> |
| 53 | + <tr> |
| 54 | + <td style={propertyColumnStyle}> |
| 55 | + <code>$ai_span_id</code> |
| 56 | + </td> |
| 57 | + <td> |
| 58 | + <p><em>(Optional)</em> Unique identifier for this embedding operation</p> |
| 59 | + </td> |
| 60 | + </tr> |
| 61 | + <tr> |
| 62 | + <td style={propertyColumnStyle}> |
| 63 | + <code>$ai_span_name</code> |
| 64 | + </td> |
| 65 | + <td> |
| 66 | + <p> |
| 67 | + <em>(Optional)</em> Name given to this embedding operation |
| 68 | + <br /> |
| 69 | + Example: <code>embed_user_query</code>, <code>index_document</code> |
| 70 | + </p> |
| 71 | + </td> |
| 72 | + </tr> |
| 73 | + <tr> |
| 74 | + <td style={propertyColumnStyle}> |
| 75 | + <code>$ai_parent_id</code> |
| 76 | + </td> |
| 77 | + <td> |
| 78 | + <p><em>(Optional)</em> Parent span ID for tree-view grouping</p> |
| 79 | + </td> |
| 80 | + </tr> |
| 81 | + <tr> |
| 82 | + <td style={propertyColumnStyle}> |
| 83 | + <code>$ai_model</code> |
| 84 | + </td> |
| 85 | + <td> |
| 86 | + <p> |
| 87 | + The embedding model used |
| 88 | + <br /> |
| 89 | + Example: <code>text-embedding-3-small</code>, <code>text-embedding-ada-002</code> |
| 90 | + </p> |
| 91 | + </td> |
| 92 | + </tr> |
| 93 | + <tr> |
| 94 | + <td style={propertyColumnStyle}> |
| 95 | + <code>$ai_provider</code> |
| 96 | + </td> |
| 97 | + <td> |
| 98 | + <p> |
| 99 | + The LLM provider |
| 100 | + <br /> |
| 101 | + Example: <code>openai</code>, <code>cohere</code>, <code>voyage</code> |
| 102 | + </p> |
| 103 | + </td> |
| 104 | + </tr> |
| 105 | + <tr> |
| 106 | + <td style={propertyColumnStyle}> |
| 107 | + <code>$ai_input</code> |
| 108 | + </td> |
| 109 | + <td> |
| 110 | + <p> |
| 111 | + The text to embed |
| 112 | + <br /> |
| 113 | + Example: <code>"Tell me a fun fact about hedgehogs"</code> or array of strings for batch embeddings |
| 114 | + </p> |
| 115 | + </td> |
| 116 | + </tr> |
| 117 | + <tr> |
| 118 | + <td style={propertyColumnStyle}> |
| 119 | + <code>$ai_input_tokens</code> |
| 120 | + </td> |
| 121 | + <td> |
| 122 | + <p>The number of tokens in the input</p> |
| 123 | + </td> |
| 124 | + </tr> |
| 125 | + <tr> |
| 126 | + <td style={propertyColumnStyle}> |
| 127 | + <code>$ai_latency</code> |
| 128 | + </td> |
| 129 | + <td> |
| 130 | + <p><em>(Optional)</em> The latency of the embedding call in seconds</p> |
| 131 | + </td> |
| 132 | + </tr> |
| 133 | + <tr> |
| 134 | + <td style={propertyColumnStyle}> |
| 135 | + <code>$ai_http_status</code> |
| 136 | + </td> |
| 137 | + <td> |
| 138 | + <p><em>(Optional)</em> The HTTP status code of the response</p> |
| 139 | + </td> |
| 140 | + </tr> |
| 141 | + <tr> |
| 142 | + <td style={propertyColumnStyle}> |
| 143 | + <code>$ai_base_url</code> |
| 144 | + </td> |
| 145 | + <td> |
| 146 | + <p> |
| 147 | + <em>(Optional)</em> The base URL of the LLM provider |
| 148 | + <br /> |
| 149 | + Example: <code>https://api.openai.com/v1</code> |
| 150 | + </p> |
| 151 | + </td> |
| 152 | + </tr> |
| 153 | + <tr> |
| 154 | + <td style={propertyColumnStyle}> |
| 155 | + <code>$ai_request_url</code> |
| 156 | + </td> |
| 157 | + <td> |
| 158 | + <p> |
| 159 | + <em>(Optional)</em> The full URL of the request made to the embedding API |
| 160 | + <br /> |
| 161 | + Example: <code>https://api.openai.com/v1/embeddings</code> |
| 162 | + </p> |
| 163 | + </td> |
| 164 | + </tr> |
| 165 | + <tr> |
| 166 | + <td style={propertyColumnStyle}> |
| 167 | + <code>$ai_is_error</code> |
| 168 | + </td> |
| 169 | + <td> |
| 170 | + <p><em>(Optional)</em> Boolean to indicate if the request was an error</p> |
| 171 | + </td> |
| 172 | + </tr> |
| 173 | + <tr> |
| 174 | + <td style={propertyColumnStyle}> |
| 175 | + <code>$ai_error</code> |
| 176 | + </td> |
| 177 | + <td> |
| 178 | + <p><em>(Optional)</em> The error message or object if the embedding failed</p> |
| 179 | + </td> |
| 180 | + </tr> |
| 181 | + </tbody> |
| 182 | + </table> |
| 183 | + </div> |
| 184 | + |
| 185 | + <Markdown> |
| 186 | + {dedent` |
| 187 | + ### Cost properties |
| 188 | +
|
| 189 | + Cost properties are optional as we can automatically calculate them from model and token counts. If you want, you can provide your own cost property instead. |
| 190 | + `} |
| 191 | + </Markdown> |
| 192 | + |
| 193 | + <div className="LemonMarkdown"> |
| 194 | + <table className="my-4"> |
| 195 | + <thead> |
| 196 | + <tr> |
| 197 | + <th style={propertyColumnStyle}>Property</th> |
| 198 | + <th>Description</th> |
| 199 | + </tr> |
| 200 | + </thead> |
| 201 | + <tbody> |
| 202 | + <tr> |
| 203 | + <td style={propertyColumnStyle}> |
| 204 | + <code>$ai_input_cost_usd</code> |
| 205 | + </td> |
| 206 | + <td> |
| 207 | + <p><em>(Optional)</em> Cost in USD for input tokens</p> |
| 208 | + </td> |
| 209 | + </tr> |
| 210 | + <tr> |
| 211 | + <td style={propertyColumnStyle}> |
| 212 | + <code>$ai_output_cost_usd</code> |
| 213 | + </td> |
| 214 | + <td> |
| 215 | + <p><em>(Optional)</em> Cost in USD for output tokens (usually 0 for embeddings)</p> |
| 216 | + </td> |
| 217 | + </tr> |
| 218 | + <tr> |
| 219 | + <td style={propertyColumnStyle}> |
| 220 | + <code>$ai_total_cost_usd</code> |
| 221 | + </td> |
| 222 | + <td> |
| 223 | + <p><em>(Optional)</em> Total cost in USD</p> |
| 224 | + </td> |
| 225 | + </tr> |
| 226 | + </tbody> |
| 227 | + </table> |
| 228 | + </div> |
| 229 | + </> |
| 230 | + ) |
| 231 | +} |
| 232 | + |
0 commit comments