Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langtrase/typescript-sdk",
"version": "6.1.1",
"version": "6.2.0",
"description": "A typescript SDK for Langtrace",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
21 changes: 9 additions & 12 deletions src/instrumentation/vercel/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ export async function generateTextPatchAnthropic (
try {
const resp = await originalMethod.apply(this, args)
const responses = JSON.stringify(resp?.responseMessages)
span.addEvent(Event.GEN_AI_PROMPT, {
'gen_ai.prompt': JSON.stringify([
{ role: 'user', content: args[0]?.prompt }
])
})
// set content to either prompt or messages
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
span.addEvent(Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
span.addEvent(Event.GEN_AI_COMPLETION, { 'gen_ai.completion': responses })
const responseAttributes: Partial<LLMSpanAttributes> = {
'url.full': url,
Expand Down Expand Up @@ -146,7 +144,8 @@ export async function streamTextPatchAnthropic (
return await context.with(trace.setSpan(context.active(), span), async () => {
try {
const resp: any = await originalMethod.apply(this, args)
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': JSON.stringify(args[0]?.prompt) })
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
const responseAttributes: Partial<LLMSpanAttributes> = {
'url.full': url,
'url.path': APIS.anthropic.MESSAGES_CREATE.ENDPOINT
Expand Down Expand Up @@ -231,11 +230,8 @@ export async function generateObjectPatchAnthropic (
try {
const resp = await originalMethod.apply(this, args)
const responses = JSON.stringify(resp?.object)
span.addEvent(Event.GEN_AI_PROMPT, {
'gen_ai.prompt': JSON.stringify([
{ role: 'user', content: args[0]?.prompt }
])
})
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
span.addEvent(Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
span.addEvent(Event.GEN_AI_COMPLETION, { 'gen_ai.completion': responses })
const responseAttributes: Partial<LLMSpanAttributes> = {
'url.full': url,
Expand Down Expand Up @@ -308,7 +304,8 @@ export async function streamObjectPatchAnthropic (
return await context.with(trace.setSpan(context.active(), span), async () => {
try {
const resp: any = await originalMethod.apply(this, args)
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': JSON.stringify(args[0]?.prompt) })
const content = args[0]?.prompt ?? JSON.stringify(args[0]?.messages)
addSpanEvent(span, Event.GEN_AI_PROMPT, { 'gen_ai.prompt': content })
const responseAttributes: Partial<LLMSpanAttributes> = {
'url.full': url,
'url.path': APIS.anthropic.MESSAGES_CREATE.ENDPOINT
Expand Down