Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor pre-release UI upgrades #340

Merged
merged 2 commits into from
Aug 28, 2024
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
53 changes: 33 additions & 20 deletions telemetry/ui/src/components/routes/app/InsightsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,24 @@ const REGISTERED_INSIGHTS: Insight[] = [
{
category: 'llm',
hasInsight: (allAttributes) => {
return allAttributes.some((attribute) => attribute.key.endsWith('prompt_tokens'));
return allAttributes.some(
(attribute) => attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')
);
},
insightName: 'Total Prompt Tokens',
RenderInsightValue: (props) => {
let totalPromptTokens = 0;
props.attributes.forEach((attribute) => {
if (attribute.key.endsWith('prompt_tokens')) {
if (attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')) {
totalPromptTokens += attribute.value as number;
}
});
return <p>{totalPromptTokens}</p>;
},
captureIndividualValues: (allAttributes) => {
return allAttributes.filter((attribute) => attribute.key.endsWith('prompt_tokens'));
return allAttributes.filter(
(attribute) => attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')
);
},
RenderIndividualValue: (props: { attribute: AttributeModel }) => {
return <p>{props.attribute.value?.toString()}</p>;
Expand All @@ -76,7 +80,10 @@ const REGISTERED_INSIGHTS: Insight[] = [
{
category: 'llm',
hasInsight: (allAttributes) => {
return allAttributes.some((attribute) => attribute.key.endsWith('completion_tokens'));
return allAttributes.some(
(attribute) =>
attribute.key.endsWith('completion_tokens') && attribute.key.startsWith('gen_ai')
);
},
insightName: 'Total Completion Tokens',
RenderInsightValue: (props) => {
Expand All @@ -89,7 +96,10 @@ const REGISTERED_INSIGHTS: Insight[] = [
return <p>{totalCompletionTokens}</p>;
},
captureIndividualValues: (allAttributes) => {
return allAttributes.filter((attribute) => attribute.key.endsWith('completion_tokens'));
return allAttributes.filter(
(attribute) =>
attribute.key.endsWith('completion_tokens') && attribute.key.startsWith('gen_ai')
);
},
RenderIndividualValue: (props: { attribute: AttributeModel }) => {
return <p>{props.attribute.value?.toString()}</p>;
Expand All @@ -98,13 +108,15 @@ const REGISTERED_INSIGHTS: Insight[] = [
{
category: 'llm',
hasInsight: (allAttributes) => {
return allAttributes.some((attribute) => attribute.key.endsWith('prompt_tokens'));
return allAttributes.some(
(attribute) => attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')
);
},
insightName: 'Total LLM Calls',
RenderInsightValue: (props) => {
let totalLLMCalls = 0;
props.attributes.forEach((attribute) => {
if (attribute.key.endsWith('prompt_tokens')) {
if (attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')) {
totalLLMCalls += 1;
}
});
Expand All @@ -113,7 +125,7 @@ const REGISTERED_INSIGHTS: Insight[] = [
captureIndividualValues: (allAttributes) => {
const spanIDToLLMCalls = new Map<string, number>();
allAttributes.forEach((attribute) => {
if (attribute.key.endsWith('prompt_tokens')) {
if (attribute.key.endsWith('prompt_tokens') && attribute.key.startsWith('gen_ai')) {
spanIDToLLMCalls.set(
attribute.span_id || '',
(spanIDToLLMCalls.get(attribute.span_id || '') || 0) + 1
Expand Down Expand Up @@ -240,12 +252,11 @@ const InsightSubTable = (props: {

export const InsightsView = (props: { steps: Step[] }) => {
const allAttributes: AttributeModel[] = props.steps.flatMap((step) => step.attributes);
let noInsights = true;

const allSpans = props.steps.flatMap((step) => step.spans);

const out = (
<div className="pt-0">
<div className="pt-0 flex flex-col">
<Table dense={1}>
<TableHead>
<TableRow className="hover:bg-gray-100">
Expand All @@ -259,7 +270,6 @@ export const InsightsView = (props: { steps: Step[] }) => {
<TableBody>
{REGISTERED_INSIGHTS.map((insight) => {
if (insight.hasInsight(allAttributes)) {
noInsights = false;
return (
<InsightSubTable
key={insight.insightName}
Expand All @@ -273,14 +283,17 @@ export const InsightsView = (props: { steps: Step[] }) => {
})}
</TableBody>
</Table>
</div>
);
if (noInsights) {
return (
<div>
<h2 className="text-gray-500 max-w-xl">
Use this tab to view summaries of your application -- E.G. LLM call data. To instrument,
and start collecting, see{' '}
<h2 className="text-gray-500 pl-2 pt-4">
Use this tab to view summaries of your application. This automatically picks up on a
variety of attributes, including those populated by{' '}
<a
className="text-dwlightblue"
href={'https://www.traceloop.com/docs/openllmetry/tracing/without-sdk'}
>
opentelemetry instrumentation.
</a>{' '}
-- E.G. LLM call data. To instrument, and start collecting, see{' '}
<a
className="text-dwlightblue"
href={'https://burr.dagworks.io/concepts/additional-visibility/#quickstart'}
Expand All @@ -289,7 +302,7 @@ export const InsightsView = (props: { steps: Step[] }) => {
</a>
</h2>
</div>
);
}
</div>
);
return out;
};
2 changes: 1 addition & 1 deletion telemetry/ui/src/components/routes/app/ReproduceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ReproduceView = (props: {
onClose={() => setIsFlashVisible(false)}
/>
)}
<div className="flex flex-row justify-between">
<div className="flex flex-row justify-between text-gray-700">
<p>
To generate a test case for this step, run the following command.
<a
Expand Down
Loading