-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracker): handle multiple docs in maintained scope
- Loading branch information
Henry Fontanier
committed
Jan 10, 2025
1 parent
cb7414d
commit 2ec0529
Showing
4 changed files
with
236 additions
and
48 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
62 changes: 62 additions & 0 deletions
62
front/lib/document_upsert_hooks/hooks/tracker/actions/doc_tracker_score_docs.ts
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,62 @@ | ||
import * as t from "io-ts"; | ||
|
||
import { callAction } from "@app/lib/actions/helpers"; | ||
import type { Authenticator } from "@app/lib/auth"; | ||
import { cloneBaseConfig, DustProdActionRegistry } from "@app/lib/registry"; | ||
|
||
export async function callDocTrackerScoreDocsAction( | ||
auth: Authenticator, | ||
{ | ||
watchedDocDiff, | ||
maintainedDocuments, | ||
providerId, | ||
modelId, | ||
}: { | ||
watchedDocDiff: string; | ||
maintainedDocuments: Array<{ | ||
content: string; | ||
title: string | null; | ||
sourceUrl: string | null; | ||
dataSourceId: string; | ||
documentId: string; | ||
}>; | ||
providerId: string; | ||
modelId: string; | ||
} | ||
): Promise<DocTrackerScoreDocsActionResult> { | ||
const action = DustProdActionRegistry["doc-tracker-score-docs"]; | ||
|
||
const config = cloneBaseConfig(action.config); | ||
config.SUGGEST_CHANGES.provider_id = providerId; | ||
config.SUGGEST_CHANGES.model_id = modelId; | ||
|
||
const res = await callAction(auth, { | ||
action, | ||
config, | ||
input: { | ||
watched_diff: watchedDocDiff, | ||
maintained_documents: maintainedDocuments, | ||
}, | ||
responseValueSchema: DocTrackerScoreDocsActionResultSchema, | ||
}); | ||
|
||
if (res.isErr()) { | ||
throw res.error; | ||
} | ||
|
||
return res.value; | ||
} | ||
|
||
const DocTrackerScoreDocsActionResultSchema = t.array( | ||
t.type({ | ||
documentId: t.string, | ||
dataSourceId: t.string, | ||
score: t.number, | ||
title: t.union([t.string, t.null, t.undefined]), | ||
sourceUrl: t.union([t.string, t.null, t.undefined]), | ||
}) | ||
); | ||
|
||
type DocTrackerScoreDocsActionResult = t.TypeOf< | ||
typeof DocTrackerScoreDocsActionResultSchema | ||
>; |
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