Skip to content

Commit 27e4c4d

Browse files
committed
Update comments
1 parent 81369d9 commit 27e4c4d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/llm-events/chat-completion-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = class LlmChatCompletionSummary extends LlmEvent {
7575

7676
/**
7777
* Sets the provided tokens counts on the LLM event.
78-
* Checks if promptToken and completionToken are greater than zero before setting.
78+
* Checks if `promptTokens` and `completionTokens` are greater than zero before setting.
7979
* This is because the spec states that token counts should only be set if both
8080
* are present.
8181
* @param {object} params to the function

lib/llm-events/event-base.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const { makeId } = require('../util/hashes')
1212
* The base LLM event class that contains logic and properties
1313
* (e.g. `trace_id`, `vendor`) that are common to all LLM events.
1414
*
15+
* Properties are defined as public fields rather than private because
16+
* these LLM event objects are serialized and then sent via the custom
17+
* event aggregator.
18+
* The property names (using snake_case like `trace_id`) must be preserved
19+
* exactly as-is in the serialized output to match the expected schema.
20+
*
1521
* @property {boolean|undefined} error Set to `true` if an error occurred
1622
* during creation call, omitted if no error occurred
1723
* @property {string} id UUID or identifier for the event
@@ -43,13 +49,15 @@ module.exports = class EventBase {
4349
this.vendor = vendor
4450
this.metadata = agent
4551

46-
// Omit `error` property if no error occurred
52+
// The spec says that the `error` property should only be
53+
// sent (via the collector) if it is set to true.
4754
if (error === true) {
4855
this.error = error
4956
}
5057

51-
// If a certain attribute value is not accessible via instrumentation,
52-
// it can be omitted from the event.
58+
// Like `error`, the spec says that if any other certain attribute value
59+
// is not accessible via instrumentation (thus `undefined`), it will be
60+
// omitted from the event.
5361
if (requestId) this.request_id = requestId
5462
if (responseModel) this['response.model'] = responseModel
5563
}

0 commit comments

Comments
 (0)