Skip to content

Commit 7595b9a

Browse files
add cleanlab score (#428) (#429)
1 parent 23be3d7 commit 7595b9a

File tree

5 files changed

+21
-34
lines changed

5 files changed

+21
-34
lines changed

README.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,39 +69,6 @@ langtrace.init(api_key='<your_api_key>') # Get your API key at langtrace.ai
6969

7070
For detailed setup instructions, see [Getting Started](#-getting-started).
7171

72-
## ✨ Features
73-
74-
- 📊 **Open Telemetry Support**: Built on OTEL standards for comprehensive tracing
75-
- 🔄 **Real-time Monitoring**: Track LLM API calls, vector operations, and framework usage
76-
- 🎯 **Performance Insights**: Analyze latency, costs, and usage patterns
77-
- 🔍 **Debug Tools**: Trace and debug your LLM application workflows
78-
- 📈 **Analytics**: Get detailed metrics and visualizations
79-
- 🏠 **Self-hosting Option**: Deploy on your own infrastructure
80-
81-
## 🚀 Quick Start
82-
83-
```bash
84-
# For TypeScript/JavaScript
85-
npm i @langtrase/typescript-sdk
86-
87-
# For Python
88-
pip install langtrace-python-sdk
89-
```
90-
91-
Initialize in your code:
92-
```typescript
93-
// TypeScript
94-
import * as Langtrace from '@langtrase/typescript-sdk'
95-
Langtrace.init({ api_key: '<your_api_key>' }) // Get your API key at langtrace.ai
96-
```
97-
```python
98-
# Python
99-
from langtrace_python_sdk import langtrace
100-
langtrace.init(api_key='<your_api_key>') # Get your API key at langtrace.ai
101-
```
102-
103-
For detailed setup instructions, see [Getting Started](#-getting-started).
104-
10572
## 📊 Open Telemetry Support
10673

10774
The traces generated by Langtrace adhere to [Open Telemetry Standards(OTEL)](https://opentelemetry.io/docs/concepts/signals/traces/). We are developing [semantic conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/) for the traces generated by this project. You can checkout the current definitions in [this repository](https://github.com/Scale3-Labs/langtrace-trace-attributes/tree/main/schemas). Note: This is an ongoing development and we encourage you to get involved and welcome your feedback.

components/project/traces/traces-table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function TracesTable<TData, TValue>({
9494
output_cost: newMode === "trace",
9595
total_cost: newMode === "trace",
9696
total_duration: newMode === "trace",
97+
cleanlab_tlm_score: false,
9798
});
9899
if (newMode === "prompt") {
99100
setFilters([

components/project/traces/traces.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,14 @@ export default function Traces({ project_id }: TracesProps) {
393393
);
394394
},
395395
},
396+
{
397+
accessorKey: "cleanlab_tlm_score",
398+
header: "Cleanlab TLM Score",
399+
cell: ({ row }) => {
400+
const score = row.getValue("cleanlab_tlm_score") as number;
401+
return <p className="text-xs font-semibold">{score}</p>;
402+
},
403+
},
396404
{
397405
accessorKey: "total_duration",
398406
header: "Total Duration",

components/shared/vendor-metadata.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ export function VendorLogo({
700700
width={80}
701701
height={80}
702702
className={cn(
703-
`${color} p-[3px]`,
703+
`${color} p-[0.5px]`,
704704
variant === "circular" ? "rounded-full" : "rounded-md"
705705
)}
706706
/>

lib/trace_util.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface Trace {
2828
sorted_trace: any[];
2929
trace_hierarchy: any[];
3030
raw_attributes: any;
31+
cleanlab_tlm_score?: number;
3132
}
3233

3334
interface TraceAttributes {
@@ -193,6 +194,7 @@ export function processTrace(trace: any): Trace {
193194
const promptVersions: string[] = [];
194195
const messages: Record<string, string[]>[] = [];
195196
const allEvents: any[] = [];
197+
let cleanlab_tlm_score: number | undefined;
196198

197199
let tokenCounts: any = {};
198200
let totalCost = { total: 0, input: 0, output: 0, cached_input: 0 };
@@ -215,6 +217,14 @@ export function processTrace(trace: any): Trace {
215217
const attrs = parseTraceAttributes(span.attributes);
216218
lastParsedAttributes = JSON.parse(span.attributes); // Keep for backward compatibility
217219

220+
// Check for CleanLab trustworthiness score
221+
if (
222+
attrs.vendor === "cleanlab" &&
223+
lastParsedAttributes["tlm.trustworthiness_score"]
224+
) {
225+
cleanlab_tlm_score = lastParsedAttributes["tlm.trustworthiness_score"];
226+
}
227+
218228
// Update collectors
219229
session_id = attrs.sessionId || session_id;
220230
type = attrs.type || type;
@@ -292,5 +302,6 @@ export function processTrace(trace: any): Trace {
292302
sorted_trace: trace,
293303
trace_hierarchy: traceHierarchy,
294304
raw_attributes: lastParsedAttributes,
305+
cleanlab_tlm_score,
295306
};
296307
}

0 commit comments

Comments
 (0)