opik 0.2.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/{Client-W52L9RIs.d.cts → Client-CI4BzUKl.d.cts} +1 -1
- package/dist/{Client-W52L9RIs.d.ts → Client-CI4BzUKl.d.ts} +1 -1
- package/dist/{chunk-POLPT3OJ.js → chunk-VUPTLXYD.js} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/vercel/index.cjs +3 -3
- package/dist/vercel/index.d.cts +1 -1
- package/dist/vercel/index.d.ts +1 -1
- package/dist/vercel/index.js +1 -1
- package/package.json +3 -1
package/dist/vercel/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OpikClient, S as Span, T as Trace } from '../Client-
|
|
1
|
+
import { O as OpikClient, S as Span, T as Trace } from '../Client-CI4BzUKl.cjs';
|
|
2
2
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
3
3
|
import { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
|
|
4
4
|
import 'stream';
|
package/dist/vercel/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OpikClient, S as Span, T as Trace } from '../Client-
|
|
1
|
+
import { O as OpikClient, S as Span, T as Trace } from '../Client-CI4BzUKl.js';
|
|
2
2
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
3
3
|
import { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
|
|
4
4
|
import 'stream';
|
package/dist/vercel/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'../chunk-
|
|
1
|
+
import {b}from'../chunk-VUPTLXYD.js';import'../chunk-WOT6VMZA.js';var s;(function(a){a[a.SUCCESS=0]="SUCCESS",a[a.FAILED=1]="FAILED";})(s||(s={}));var I=new b,c=class{constructor({client:r=I}={}){this.traces=new Map;this.spans=new Map;this.getSpanInput=r=>{let e={},{attributes:t}=r;return Object.keys(t).forEach(o=>{if(o==="ai.prompt"||o==="gen_ai.request"){let n=h(t[o]);n&&(e={...e,...n});}if(o.startsWith("ai.prompt.")){let n=o.replace("ai.prompt.","");e[n]=m(t[o]);}if(o.startsWith("gen_ai.request.")){let n=o.replace("gen_ai.request.","");e[n]=m(t[o]);}}),Object.keys(e).length>0||("ai.toolCall.name"in t&&(e.toolName=t["ai.toolCall.name"]),"ai.toolCall.args"in t&&(e.args=t["ai.toolCall.args"])),e};this.getSpanOutput=r=>{let{attributes:e}=r;return e["ai.response.text"]?{text:e["ai.response.text"]}:e["ai.toolCall.result"]?{result:e["ai.toolCall.result"]}:e["ai.response.toolCalls"]?{toolCalls:m(e["ai.response.toolCalls"])}:{}};this.getSpanMetadata=r=>{let{attributes:e}=r,t={};return e["gen_ai.response.model"]&&(t.model=e["gen_ai.response.model"]),e["gen_ai.system"]&&(t.system=e["gen_ai.system"]),t};this.getSpanUsage=r=>{let{attributes:e}=r,t={};return "ai.usage.promptTokens"in e&&(t.prompt_tokens=e["ai.usage.promptTokens"]),"gen_ai.usage.input_tokens"in e&&(t.prompt_tokens=e["gen_ai.usage.input_tokens"]),"ai.usage.completionTokens"in e&&(t.completion_tokens=e["ai.usage.completionTokens"]),"gen_ai.usage.output_tokens"in e&&(t.completion_tokens=e["gen_ai.usage.output_tokens"]),("prompt_tokens"in t||"completion_tokens"in t)&&(t.total_tokens=(t.prompt_tokens||0)+(t.completion_tokens||0)),t};this.processSpan=({otelSpan:r,parentSpan:e,trace:t})=>t.span({name:r.name,startTime:new Date(p(r.startTime)),endTime:new Date(p(r.endTime)),parentSpanId:e==null?void 0:e.data.id,input:this.getSpanInput(r),output:this.getSpanOutput(r),metadata:this.getSpanMetadata(r),usage:this.getSpanUsage(r),type:"llm"});this.shutdown=async()=>{await this.client.flush();};this.forceFlush=async()=>{await this.client.flush();};this.export=(r,e)=>{let t=_(r);Object.entries(t).forEach(([i,o])=>{var d,g;let[n,...S]=o,l=this.client.trace({startTime:new Date(p(n.startTime)),endTime:new Date(p(n.endTime)),name:(g=(d=n.attributes["ai.telemetry.metadata.traceName"])==null?void 0:d.toString())!=null?g:n.name,input:this.getSpanInput(n),output:this.getSpanOutput(n),metadata:this.getSpanMetadata(n),usage:this.getSpanUsage(n)});this.traces.set(i,l),S.forEach(u=>{var f;let x=this.spans.get((f=u.parentSpanId)!=null?f:""),E=this.processSpan({parentSpan:x,otelSpan:u,trace:l});this.spans.set(u.spanContext().spanId,E);});}),e({code:s.SUCCESS});};this.client=r;}static getSettings(r){var t,i,o;let e={...r.metadata};return r.name&&(e.traceName=r.name),{isEnabled:(t=r.isEnabled)!=null?t:true,recordInputs:(i=r.recordInputs)!=null?i:true,recordOutputs:(o=r.recordOutputs)!=null?o:true,functionId:r.functionId,metadata:e}}};function _(a){let r={};return a.forEach(e=>{let t=e.spanContext();r[t.traceId]||(r[t.traceId]=[]),r[t.traceId].push(e);}),Object.values(r).forEach(e=>{e.sort((t,i)=>{if(!t.parentSpanId&&i.parentSpanId)return -1;if(t.parentSpanId&&!i.parentSpanId)return 1;if(t.parentSpanId&&i.parentSpanId){if(t.parentSpanId===i.spanContext().spanId)return 1;if(i.parentSpanId===t.spanContext().spanId)return -1}return 0});}),r}function p(a){return a[0]*1e3+a[1]/1e6}function m(a){try{return JSON.parse(a)}catch{return a}}function h(a){if(typeof a=="string")try{let r=JSON.parse(a);if(r!==null&&typeof r=="object"&&!Array.isArray(r))return r}catch{return}}export{c as OpikExporter};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opik",
|
|
3
3
|
"description": "Opik TypeScript and JavaScript SDK",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/comet-ml/opik.git",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@opentelemetry/api": "^1.9.0",
|
|
63
63
|
"@opentelemetry/auto-instrumentations-node": "^0.56.0",
|
|
64
64
|
"@opentelemetry/sdk-node": "^0.57.1",
|
|
65
|
+
"@types/ini": "^4.1.1",
|
|
65
66
|
"@types/node-fetch": "^2.6.12",
|
|
66
67
|
"@types/qs": "^6.9.17",
|
|
67
68
|
"@types/readable-stream": "^4.0.18",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
},
|
|
89
90
|
"dependencies": {
|
|
90
91
|
"ansi-escapes": "^7.0.0",
|
|
92
|
+
"ini": "^5.0.0",
|
|
91
93
|
"node-fetch": "^3.3.2",
|
|
92
94
|
"qs": "^6.13.1",
|
|
93
95
|
"readable-stream": "^4.7.0",
|