Skip to content

Commit 32db6c0

Browse files
committed
remove unecessary changes
1 parent c364dfd commit 32db6c0

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

packages/dd-trace/src/llmobs/tagger.js

+31-11
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ class LLMObsTagger {
195195

196196
const documentObj = { text }
197197

198-
validDocument = this._tagConditional('string', name, 'Document name', documentObj, 'name') && validDocument
199-
validDocument = this._tagConditional('string', id, 'Document ID', documentObj, 'id') && validDocument
200-
validDocument = this._tagConditional('number', score, 'Document score', documentObj, 'score') && validDocument
198+
validDocument = this._tagConditionalString(name, 'Document name', documentObj, 'name') && validDocument
199+
validDocument = this._tagConditionalString(id, 'Document ID', documentObj, 'id') && validDocument
200+
validDocument = this._tagConditionalNumber(score, 'Document score', documentObj, 'score') && validDocument
201201

202202
return validDocument ? documentObj : undefined
203203
}).filter(doc => !!doc)
@@ -235,7 +235,7 @@ class LLMObsTagger {
235235
validMessage = false
236236
}
237237

238-
validMessage = this._tagConditional('string', role, 'Message role', messageObj, 'role') && validMessage
238+
validMessage = this._tagConditionalString(role, 'Message role', messageObj, 'role') && validMessage
239239

240240
if (toolCalls) {
241241
if (!Array.isArray(toolCalls)) {
@@ -253,10 +253,10 @@ class LLMObsTagger {
253253
const { name, arguments: args, toolId, type } = toolCall
254254
const toolCallObj = {}
255255

256-
validTool = this._tagConditional('string', name, 'Tool name', toolCallObj, 'name') && validTool
257-
validTool = this._tagConditional('object', args, 'Tool arguments', toolCallObj, 'arguments') && validTool
258-
validTool = this._tagConditional('string', toolId, 'Tool ID', toolCallObj, 'tool_id') && validTool
259-
validTool = this._tagConditional('string', type, 'Tool type', toolCallObj, 'type') && validTool
256+
validTool = this._tagConditionalString(name, 'Tool name', toolCallObj, 'name') && validTool
257+
validTool = this._tagConditionalObject(args, 'Tool arguments', toolCallObj, 'arguments') && validTool
258+
validTool = this._tagConditionalString(toolId, 'Tool ID', toolCallObj, 'tool_id') && validTool
259+
validTool = this._tagConditionalString(type, 'Tool type', toolCallObj, 'type') && validTool
260260

261261
return validTool ? toolCallObj : undefined
262262
}).filter(toolCall => !!toolCall)
@@ -275,10 +275,30 @@ class LLMObsTagger {
275275
}
276276
}
277277

278-
_tagConditional (dataType, data, type, carrier, key) {
278+
_tagConditionalString (data, type, carrier, key) {
279279
if (!data) return true
280-
if (typeof data !== dataType) { // eslint-disable-line valid-typeof
281-
this._handleFailure(`"${type}" must be of type "${dataType}".`)
280+
if (typeof data !== 'string') {
281+
this._handleFailure(`"${type}" must be a string.`)
282+
return false
283+
}
284+
carrier[key] = data
285+
return true
286+
}
287+
288+
_tagConditionalNumber (data, type, carrier, key) {
289+
if (!data) return true
290+
if (typeof data !== 'number') {
291+
this._handleFailure(`"${type}" must be a number.`)
292+
return false
293+
}
294+
carrier[key] = data
295+
return true
296+
}
297+
298+
_tagConditionalObject (data, type, carrier, key) {
299+
if (!data) return true
300+
if (typeof data !== 'object') {
301+
this._handleFailure(`"${type}" must be an object.`)
282302
return false
283303
}
284304
carrier[key] = data

0 commit comments

Comments
 (0)