Skip to content

Commit 0afd3bb

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: backend functionality for filtering on event_type for
topic_events and sending ll events to frontend
1 parent 794bcb4 commit 0afd3bb

8 files changed

Lines changed: 190 additions & 142 deletions

File tree

clients/ts-sdk/openapi.json

Lines changed: 96 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9047,6 +9047,66 @@
90479047
"rag"
90489048
]
90499049
},
9050+
"ClickhouseTopicAnalyticsSummary": {
9051+
"type": "object",
9052+
"required": [
9053+
"id",
9054+
"name",
9055+
"topic_id",
9056+
"owner_id",
9057+
"created_at",
9058+
"updated_at",
9059+
"message_count",
9060+
"avg_top_score",
9061+
"avg_hallucination_score",
9062+
"products_shown"
9063+
],
9064+
"properties": {
9065+
"avg_hallucination_score": {
9066+
"type": "number",
9067+
"format": "double"
9068+
},
9069+
"avg_query_rating": {
9070+
"type": "number",
9071+
"format": "double",
9072+
"nullable": true
9073+
},
9074+
"avg_top_score": {
9075+
"type": "number",
9076+
"format": "double"
9077+
},
9078+
"created_at": {
9079+
"type": "string"
9080+
},
9081+
"id": {
9082+
"type": "string",
9083+
"format": "uuid"
9084+
},
9085+
"message_count": {
9086+
"type": "integer",
9087+
"format": "int64",
9088+
"minimum": 0
9089+
},
9090+
"name": {
9091+
"type": "string"
9092+
},
9093+
"owner_id": {
9094+
"type": "string"
9095+
},
9096+
"products_shown": {
9097+
"type": "integer",
9098+
"format": "int64",
9099+
"minimum": 0
9100+
},
9101+
"topic_id": {
9102+
"type": "string",
9103+
"format": "uuid"
9104+
},
9105+
"updated_at": {
9106+
"type": "string"
9107+
}
9108+
}
9109+
},
90509110
"CloneTopicReqPayload": {
90519111
"type": "object",
90529112
"required": [
@@ -15319,10 +15379,6 @@
1531915379
],
1532015380
"nullable": true
1532115381
},
15322-
"has_clicks": {
15323-
"type": "boolean",
15324-
"nullable": true
15325-
},
1532615382
"page": {
1532715383
"type": "integer",
1532815384
"format": "int32",
@@ -15345,6 +15401,14 @@
1534515401
],
1534615402
"nullable": true
1534715403
},
15404+
"topic_events_filter": {
15405+
"allOf": [
15406+
{
15407+
"$ref": "#/components/schemas/TopicEventFilter"
15408+
}
15409+
],
15410+
"nullable": true
15411+
},
1534815412
"type": {
1534915413
"type": "string",
1535015414
"enum": [
@@ -20206,66 +20270,6 @@
2020620270
}
2020720271
}
2020820272
},
20209-
"TopicAnalyticsSummary": {
20210-
"type": "object",
20211-
"required": [
20212-
"id",
20213-
"name",
20214-
"topic_id",
20215-
"owner_id",
20216-
"created_at",
20217-
"updated_at",
20218-
"message_count",
20219-
"avg_top_score",
20220-
"avg_hallucination_score",
20221-
"products_shown"
20222-
],
20223-
"properties": {
20224-
"avg_hallucination_score": {
20225-
"type": "number",
20226-
"format": "double"
20227-
},
20228-
"avg_query_rating": {
20229-
"type": "number",
20230-
"format": "double",
20231-
"nullable": true
20232-
},
20233-
"avg_top_score": {
20234-
"type": "number",
20235-
"format": "double"
20236-
},
20237-
"created_at": {
20238-
"type": "string"
20239-
},
20240-
"id": {
20241-
"type": "string",
20242-
"format": "uuid"
20243-
},
20244-
"message_count": {
20245-
"type": "integer",
20246-
"format": "int64",
20247-
"minimum": 0
20248-
},
20249-
"name": {
20250-
"type": "string"
20251-
},
20252-
"owner_id": {
20253-
"type": "string"
20254-
},
20255-
"products_shown": {
20256-
"type": "integer",
20257-
"format": "int64",
20258-
"minimum": 0
20259-
},
20260-
"topic_id": {
20261-
"type": "string",
20262-
"format": "uuid"
20263-
},
20264-
"updated_at": {
20265-
"type": "string"
20266-
}
20267-
}
20268-
},
2026920273
"TopicDetailsResponse": {
2027020274
"type": "object",
2027120275
"required": [
@@ -20284,16 +20288,42 @@
2028420288
}
2028520289
}
2028620290
},
20291+
"TopicEventFilter": {
20292+
"type": "object",
20293+
"required": [
20294+
"event_types",
20295+
"inverted"
20296+
],
20297+
"properties": {
20298+
"event_types": {
20299+
"type": "array",
20300+
"items": {
20301+
"$ref": "#/components/schemas/EventTypesFilter"
20302+
},
20303+
"description": "Filter by event type"
20304+
},
20305+
"inverted": {
20306+
"type": "boolean"
20307+
}
20308+
}
20309+
},
2028720310
"TopicQueriesResponse": {
2028820311
"type": "object",
2028920312
"required": [
20290-
"topics"
20313+
"topics",
20314+
"events"
2029120315
],
2029220316
"properties": {
20317+
"events": {
20318+
"type": "array",
20319+
"items": {
20320+
"$ref": "#/components/schemas/EventData"
20321+
}
20322+
},
2029320323
"topics": {
2029420324
"type": "array",
2029520325
"items": {
20296-
"$ref": "#/components/schemas/TopicAnalyticsSummary"
20326+
"$ref": "#/components/schemas/ClickhouseTopicAnalyticsSummary"
2029720327
}
2029820328
}
2029920329
}

clients/ts-sdk/src/types.gen.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,20 @@ export type ClickhouseRecommendationTypes = 'Chunk' | 'Group';
552552

553553
export type ClickhouseSearchTypes = 'search' | 'search_over_groups' | 'autocomplete' | 'rag';
554554

555+
export type ClickhouseTopicAnalyticsSummary = {
556+
avg_hallucination_score: number;
557+
avg_query_rating?: (number) | null;
558+
avg_top_score: number;
559+
created_at: string;
560+
id: string;
561+
message_count: number;
562+
name: string;
563+
owner_id: string;
564+
products_shown: number;
565+
topic_id: string;
566+
updated_at: string;
567+
};
568+
555569
export type CloneTopicReqPayload = {
556570
/**
557571
* The name of the topic. If this is not provided, the topic name is the same as the previous topic
@@ -2826,10 +2840,10 @@ export type RAGAnalytics = {
28262840
type: 'followup_queries';
28272841
} | {
28282842
filter?: ((TopicAnalyticsFilter) | null);
2829-
has_clicks?: (boolean) | null;
28302843
page?: (number) | null;
28312844
sort_by?: ((RAGSortBy) | null);
28322845
sort_order?: ((SortOrder) | null);
2846+
topic_events_filter?: ((TopicEventFilter) | null);
28332847
type: 'topic_queries';
28342848
} | {
28352849
topic_id: string;
@@ -4078,27 +4092,22 @@ export type TopicAnalyticsFilter = {
40784092
top_score?: ((FloatRange) | null);
40794093
};
40804094

4081-
export type TopicAnalyticsSummary = {
4082-
avg_hallucination_score: number;
4083-
avg_query_rating?: (number) | null;
4084-
avg_top_score: number;
4085-
created_at: string;
4086-
id: string;
4087-
message_count: number;
4088-
name: string;
4089-
owner_id: string;
4090-
products_shown: number;
4091-
topic_id: string;
4092-
updated_at: string;
4093-
};
4094-
40954095
export type TopicDetailsResponse = {
40964096
messages: Array<RagQueryEvent>;
40974097
topic: TopicQuery;
40984098
};
40994099

4100+
export type TopicEventFilter = {
4101+
/**
4102+
* Filter by event type
4103+
*/
4104+
event_types: Array<EventTypesFilter>;
4105+
inverted: boolean;
4106+
};
4107+
41004108
export type TopicQueriesResponse = {
4101-
topics: Array<TopicAnalyticsSummary>;
4109+
events: Array<EventData>;
4110+
topics: Array<ClickhouseTopicAnalyticsSummary>;
41024111
};
41034112

41044113
export type TopicQuery = {

frontends/search/src/components/OrgGroupPageView.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
5555
);
5656
const [prevGroupOffsets, setPrevGroupOffsets] = createSignal<string[]>([]);
5757
const [nextGroupOffset, setNextGroupOffset] = createSignal<string | null>(
58-
null
58+
null,
5959
);
6060

6161
const [groupPageCount, setGroupPageCount] = createSignal(1);
@@ -175,7 +175,8 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
175175
setLoading(true);
176176

177177
void fetch(
178-
`${apiHost}/dataset/groups/${currentDataset.dataset.id
178+
`${apiHost}/dataset/groups/${
179+
currentDataset.dataset.id
179180
}/?use_cursor=true&cursor=${groupOffset()}`,
180181
{
181182
method: "GET",
@@ -231,7 +232,8 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
231232
return (delete_chunks: boolean) => {
232233
setDeleting(true);
233234
void fetch(
234-
`${apiHost}/chunk_group/${group.id
235+
`${apiHost}/chunk_group/${
236+
group.id
235237
}?delete_chunks=${delete_chunks.toString()}`,
236238
{
237239
method: "DELETE",
@@ -366,9 +368,9 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
366368
each={
367369
searchQuery()
368370
? searchResults().slice(
369-
(groupPage() - 1) * 10,
370-
groupPage() * 10,
371-
)
371+
(groupPage() - 1) * 10,
372+
groupPage() * 10,
373+
)
372374
: groups()
373375
}
374376
>
@@ -410,7 +412,7 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
410412
<Show
411413
when={
412414
serverConfig()?.["DOCUMENT_DOWNLOAD_FEATURE"] !=
413-
false && group.file_id
415+
false && group.file_id
414416
}
415417
>
416418
<button
@@ -470,22 +472,27 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
470472
</button>
471473
<button
472474
class="disabled:text-neutral-400 dark:disabled:text-neutral-500"
473-
disabled={groupPage() == groupPageCount() && nextGroupOffset() == null}
475+
disabled={
476+
groupPage() == groupPageCount() && nextGroupOffset() == null
477+
}
474478
onClick={() => {
475479
setGroupPage((prev) => prev + 1);
476480
const currentGroupOffset = groupOffset();
477481
setGroupOffset(nextGroupOffset());
478482
if (currentGroupOffset != null) {
479-
setPrevGroupOffsets((prevGroups) => [...prevGroups, currentGroupOffset]);
483+
setPrevGroupOffsets((prevGroups) => [
484+
...prevGroups,
485+
currentGroupOffset,
486+
]);
480487
}
481488
}}
482489
>
483490
<BiRegularChevronRight class="h-6 w-6 fill-current" />
484491
</button>
485492
</div>
486493
</div>
487-
</Show >
488-
</div >
494+
</Show>
495+
</div>
489496
</>
490497
);
491498
};

0 commit comments

Comments
 (0)