Skip to content

Commit

Permalink
Merge branch 'development' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikscale3 committed Nov 18, 2024
2 parents ee6ba88 + 5e18941 commit f60a40a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
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

0 comments on commit f60a40a

Please sign in to comment.