Skip to content

Commit

Permalink
feat: query logic
Browse files Browse the repository at this point in the history
  • Loading branch information
skoob13 committed Jan 14, 2025
1 parent 16d62c3 commit c6da4a2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions frontend/src/queries/schema/schema-general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export type AnyDataNode =
| ExperimentFunnelsQuery
| ExperimentTrendsQuery
| RecordingsQuery
| TracesQuery

/**
* @discriminator kind
Expand Down Expand Up @@ -633,6 +634,7 @@ export interface DataTableNode
| ErrorTrackingQuery
| ExperimentFunnelsQuery
| ExperimentTrendsQuery
| TracesQuery
)['response']
>
>,
Expand All @@ -653,6 +655,7 @@ export interface DataTableNode
| ErrorTrackingQuery
| ExperimentFunnelsQuery
| ExperimentTrendsQuery
| TracesQuery
/** Columns shown in the table, unless the `source` provides them. */
columns?: HogQLExpression[]
/** Columns that aren't shown in the table, even if in columns or returned data */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { useValues } from 'kea'

import { Query } from '~/queries/Query/Query'

import { llmObservabilityLogic } from './llmObservabilityLogic'

export function LLMObservabilityTraces(): JSX.Element {
return <div>Traces</div>
const { query } = useValues(llmObservabilityLogic)
return <Query query={query} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { STALE_EVENT_SECONDS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { getTracesQuery } from 'scenes/llm-observability/queries'

import { NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
import {
Expand Down Expand Up @@ -47,6 +48,7 @@ export const llmObservabilityLogic = kea<llmObservabilityLogicType>([
setDates: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
setShouldFilterTestAccounts: (shouldFilterTestAccounts: boolean) => ({ shouldFilterTestAccounts }),
setActiveTab: (activeTab: LLMObservabilityTab) => ({ activeTab }),
loadMoreTraces: true,
}),

reducers({
Expand All @@ -66,6 +68,7 @@ export const llmObservabilityLogic = kea<llmObservabilityLogicType>([
},
],
activeTab: [LLMObservabilityTab.Dashboard, { setActiveTab: (_, { activeTab }) => activeTab }],
queryLimit: [30, { setQueryLimit: (_, { queryLimit }) => queryLimit + 30 }],
}),

selectors({
Expand Down Expand Up @@ -238,6 +241,7 @@ export const llmObservabilityLogic = kea<llmObservabilityLogicType>([
},
],
],
query: [(s) => [s.queryLimit], (queryLimit) => getTracesQuery({ limit: queryLimit })],
}),
loaders({
hasSentAiGenerationEvent: {
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/scenes/llm-observability/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DataTableNode, NodeKind, TracesQuery } from '~/queries/schema/schema-general'

type GetTracesQueryParams = Pick<TracesQuery, 'limit'>

export function getTracesQuery({ limit }: GetTracesQueryParams): DataTableNode {
return {
kind: NodeKind.DataTableNode,
source: {
kind: NodeKind.TracesQuery,
limit: limit,
},
showActions: false,
showTimings: false,
// columns: columns,
}
}

0 comments on commit c6da4a2

Please sign in to comment.