Skip to content

Commit ee9c7e1

Browse files
karthikscale3darshit-s3obinnaokaforobinnascale3rohit-kadhe
authored
Release (#191)
* feat: adding gemini support (#162) * feat: adding gemini support * chore: update package lock * docs: update changelog for 5.2.0 release * feat: adding vertexai instrumentation support (#165) * feat: adding vertexai instrumentation support * style: remove commented import * chore: create types for vertexai * docs: revert vercel ai py check * docs: add mistral check * style: remove new lines * docs: add vertexai to changelog (#166) * fix: allow manual patch for Gemini and VertexAI (#169) * star github link * feat: adding vertexai tools tracing support (#172) * add mistral instrumentation * support otel env vars * bump version adn add chat stream method * add examples * update readme * update package-lock * Add sentry integration * merge with dev * llama index enhacements * sentry to filter non langtrace exceptions * Fix ingestion url (#181) * Obinna/s3 en 2724 add bedrock (#184) * add aws bedrock converse implementation * bump version * cleanup and update readme * update service type * fixes --------- Co-authored-by: Obinna Okafor <[email protected]> Co-authored-by: Karthik Kalyanaraman <[email protected]> * fix (#186) * update readme * fix * update prompt (#190) --------- Co-authored-by: darshit-s3 <[email protected]> Co-authored-by: Darshit Suratwala <[email protected]> Co-authored-by: Obinna Okafor <[email protected]> Co-authored-by: obinnascale3 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]>
1 parent 9a3b15e commit ee9c7e1

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@langtrase/typescript-sdk",
3-
"version": "6.1.1",
3+
"version": "6.2.0",
44
"description": "A typescript SDK for Langtrace",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/instrumentation/vercel/anthropic.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ export async function generateTextPatchAnthropic (
6969
try {
7070
const resp = await originalMethod.apply(this, args)
7171
const responses = JSON.stringify(resp?.responseMessages)
72-
span.addEvent(Event.GEN_AI_PROMPT, {
73-
'gen_ai.prompt': JSON.stringify([
74-
{ role: 'user', content: args[0]?.prompt }
75-
])
76-
})
72+
// set content to either prompt or messages
73+
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
74+
span.addEvent(Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
7775
span.addEvent(Event.GEN_AI_COMPLETION, { 'gen_ai.completion': responses })
7876
const responseAttributes: Partial<LLMSpanAttributes> = {
7977
'url.full': url,
@@ -146,7 +144,8 @@ export async function streamTextPatchAnthropic (
146144
return await context.with(trace.setSpan(context.active(), span), async () => {
147145
try {
148146
const resp: any = await originalMethod.apply(this, args)
149-
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': JSON.stringify(args[0]?.prompt) })
147+
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
148+
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
150149
const responseAttributes: Partial<LLMSpanAttributes> = {
151150
'url.full': url,
152151
'url.path': APIS.anthropic.MESSAGES_CREATE.ENDPOINT
@@ -231,11 +230,8 @@ export async function generateObjectPatchAnthropic (
231230
try {
232231
const resp = await originalMethod.apply(this, args)
233232
const responses = JSON.stringify(resp?.object)
234-
span.addEvent(Event.GEN_AI_PROMPT, {
235-
'gen_ai.prompt': JSON.stringify([
236-
{ role: 'user', content: args[0]?.prompt }
237-
])
238-
})
233+
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
234+
span.addEvent(Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
239235
span.addEvent(Event.GEN_AI_COMPLETION, { 'gen_ai.completion': responses })
240236
const responseAttributes: Partial<LLMSpanAttributes> = {
241237
'url.full': url,
@@ -308,7 +304,8 @@ export async function streamObjectPatchAnthropic (
308304
return await context.with(trace.setSpan(context.active(), span), async () => {
309305
try {
310306
const resp: any = await originalMethod.apply(this, args)
311-
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': JSON.stringify(args[0]?.prompt) })
307+
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
308+
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
312309
const responseAttributes: Partial<LLMSpanAttributes> = {
313310
'url.full': url,
314311
'url.path': APIS.anthropic.MESSAGES_CREATE.ENDPOINT

0 commit comments

Comments
 (0)