-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(llm-obs): LLM observability dashboard (#27415)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Peter Kirkham <[email protected]>
- Loading branch information
1 parent
b8a2764
commit 31112ea
Showing
18 changed files
with
627 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
frontend/src/scenes/llm-observability/LLMObservabilityScene.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import clsx from 'clsx' | ||
import { BindLogic, useActions, useValues } from 'kea' | ||
import { DateFilter } from 'lib/components/DateFilter/DateFilter' | ||
import { SceneExport } from 'scenes/sceneTypes' | ||
|
||
import { navigationLogic } from '~/layout/navigation/navigationLogic' | ||
import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic' | ||
import { Query } from '~/queries/Query/Query' | ||
import { NodeKind } from '~/queries/schema' | ||
|
||
import { LLM_OBSERVABILITY_DATA_COLLECTION_NODE_ID, llmObservabilityLogic, QueryTile } from './llmObservabilityLogic' | ||
|
||
export const scene: SceneExport = { | ||
component: LLMObservabilityScene, | ||
} | ||
|
||
const Filters = (): JSX.Element => { | ||
const { | ||
dateFilter: { dateTo, dateFrom }, | ||
} = useValues(llmObservabilityLogic) | ||
const { setDates } = useActions(llmObservabilityLogic) | ||
const { mobileLayout } = useValues(navigationLogic) | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
'sticky z-20 bg-bg-3000', | ||
mobileLayout ? 'top-[var(--breadcrumbs-height-full)]' : 'top-[var(--breadcrumbs-height-compact)]' | ||
)} | ||
> | ||
<div className="border-b py-2 flex flex-row flex-wrap gap-2 md:[&>*]:grow-0 [&>*]:grow"> | ||
<DateFilter dateFrom={dateFrom} dateTo={dateTo} onChange={setDates} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const Tiles = (): JSX.Element => { | ||
const { tiles } = useValues(llmObservabilityLogic) | ||
|
||
return ( | ||
<div className="mt-2 grid grid-cols-1 md:grid-cols-2 xxl:grid-cols-3 gap-4"> | ||
{tiles.map((tile, i) => ( | ||
<QueryTileItem key={i} tile={tile} /> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
const QueryTileItem = ({ tile }: { tile: QueryTile }): JSX.Element => { | ||
const { query, title, layout } = tile | ||
|
||
return ( | ||
<div className={clsx('col-span-1 row-span-1 flex flex-col', layout?.className)}> | ||
{title && <h2 className="mb-1 flex flex-row ml-1">{title}</h2>} | ||
<Query query={{ kind: NodeKind.InsightVizNode, source: query }} readOnly /> | ||
</div> | ||
) | ||
} | ||
|
||
export function LLMObservabilityScene(): JSX.Element { | ||
return ( | ||
<BindLogic logic={dataNodeCollectionLogic} props={{ key: LLM_OBSERVABILITY_DATA_COLLECTION_NODE_ID }}> | ||
<Filters /> | ||
<Tiles /> | ||
</BindLogic> | ||
) | ||
} |
93 changes: 93 additions & 0 deletions
93
frontend/src/scenes/llm-observability/llmObservabilityLogic.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { actions, kea, path, reducers, selectors } from 'kea' | ||
|
||
import { NodeKind, TrendsQuery } from '~/queries/schema' | ||
import { PropertyMathType } from '~/types' | ||
|
||
import type { llmObservabilityLogicType } from './llmObservabilityLogicType' | ||
|
||
export const LLM_OBSERVABILITY_DATA_COLLECTION_NODE_ID = 'llm-observability-data' | ||
|
||
const INITIAL_DATE_FROM = '-30d' as string | null | ||
const INITIAL_DATE_TO = null as string | null | ||
|
||
export interface QueryTile { | ||
title: string | ||
query: TrendsQuery | ||
layout?: { | ||
className?: string | ||
} | ||
} | ||
|
||
export const llmObservabilityLogic = kea<llmObservabilityLogicType>([ | ||
path(['scenes', 'llm-observability', 'llmObservabilityLogic']), | ||
|
||
actions({ | ||
setDates: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }), | ||
}), | ||
|
||
reducers({ | ||
dateFilter: [ | ||
{ | ||
dateFrom: INITIAL_DATE_FROM, | ||
dateTo: INITIAL_DATE_TO, | ||
}, | ||
{ | ||
setDates: (_, { dateFrom, dateTo }) => ({ dateFrom, dateTo }), | ||
}, | ||
], | ||
}), | ||
|
||
selectors({ | ||
tiles: [ | ||
(s) => [s.dateFilter], | ||
(dateFilter): QueryTile[] => [ | ||
{ | ||
title: 'LLM generations', | ||
query: { | ||
kind: NodeKind.TrendsQuery, | ||
series: [ | ||
{ | ||
event: '$ai_generation', | ||
kind: NodeKind.EventsNode, | ||
}, | ||
], | ||
dateRange: { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }, | ||
}, | ||
}, | ||
{ | ||
title: 'LLM costs (USD)', | ||
query: { | ||
kind: NodeKind.TrendsQuery, | ||
series: [ | ||
{ | ||
event: '$ai_generation', | ||
math: PropertyMathType.Sum, | ||
kind: NodeKind.EventsNode, | ||
math_property: '$ai_total_cost_usd', | ||
}, | ||
], | ||
dateRange: { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }, | ||
}, | ||
}, | ||
{ | ||
title: 'Average latency (ms)', | ||
query: { | ||
kind: NodeKind.TrendsQuery, | ||
series: [ | ||
{ | ||
event: '$ai_generation', | ||
math: PropertyMathType.Average, | ||
kind: NodeKind.EventsNode, | ||
math_property: '$ai_latency', | ||
}, | ||
], | ||
breakdownFilter: { | ||
breakdown: '$ai_model', | ||
}, | ||
dateRange: { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }, | ||
}, | ||
}, | ||
], | ||
], | ||
}), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .hedgebox import HedgeboxMatrix | ||
from .spikegpt import SpikeGPTMatrix | ||
|
||
__all__ = ["HedgeboxMatrix"] | ||
__all__ = ["HedgeboxMatrix", "SpikeGPTMatrix"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .matrix import SpikeGPTMatrix | ||
|
||
# This is a simulation of a ChatGPT clone called SpikeGPT | ||
|
||
__all__ = ["SpikeGPTMatrix"] |
Oops, something went wrong.