mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(lens): keep polling a finished run until its last reviews arrive
This commit is contained in:
parent
e50f53965d
commit
f0c2baf254
1 changed files with 7 additions and 4 deletions
|
|
@ -5,13 +5,16 @@ import { useState } from "react";
|
|||
|
||||
import { lensQueries } from "../../api/queries";
|
||||
import type { LensApi } from "../../api/service";
|
||||
import { appendPage, EMPTY_FEED, type ReviewFeed } from "../../model/live";
|
||||
import { appendPage, EMPTY_FEED, polling, type ReviewFeed } from "../../model/live";
|
||||
import type { Job, Review } from "../../model/types";
|
||||
|
||||
export function useJobReviews(api: LensApi, lensId: string, job: Pick<Job, "id" | "status">): readonly Review[] {
|
||||
export function useJobReviews(
|
||||
api: LensApi,
|
||||
lensId: string,
|
||||
job: Pick<Job, "id" | "status" | "reviewed">,
|
||||
): readonly Review[] {
|
||||
const [feed, setFeed] = useState<ReviewFeed>(EMPTY_FEED);
|
||||
const live = job.status === "queued" || job.status === "running";
|
||||
const page = { lensId, jobId: job.id, after: feed.cursor, live };
|
||||
const page = { lensId, jobId: job.id, after: feed.cursor, live: polling(job, feed) };
|
||||
const { data } = useQuery(lensQueries.reviews(api, page));
|
||||
const next = data ? appendPage(feed, data) : feed;
|
||||
if (next !== feed) setFeed(next);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue