mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-16 00:31:02 +02:00
fix: remove test import (#1017)
Convention in the tests is to just import the libraries as production code would. This is fragile, and could possibly be used to inject malicious code in the CI environment.
This commit is contained in:
parent
f04ae5331d
commit
c05296376e
1 changed files with 3 additions and 25 deletions
|
|
@ -1,30 +1,8 @@
|
||||||
import importlib.util
|
from trustgraph.retrieval.document_rag.rerank import (
|
||||||
from pathlib import Path
|
RerankCandidate, normalize_candidate_scores, mmr_select,
|
||||||
|
_pair_diversity_penalty
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parents[3]
|
|
||||||
RERANK_PATH = (
|
|
||||||
REPO_ROOT
|
|
||||||
/ "trustgraph-flow"
|
|
||||||
/ "trustgraph"
|
|
||||||
/ "retrieval"
|
|
||||||
/ "document_rag"
|
|
||||||
/ "rerank.py"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location(
|
|
||||||
"document_rag_diversity_rerank",
|
|
||||||
RERANK_PATH,
|
|
||||||
)
|
|
||||||
rerank = importlib.util.module_from_spec(spec)
|
|
||||||
spec.loader.exec_module(rerank)
|
|
||||||
|
|
||||||
RerankCandidate = rerank.RerankCandidate
|
|
||||||
normalize_candidate_scores = rerank.normalize_candidate_scores
|
|
||||||
mmr_select = rerank.mmr_select
|
|
||||||
_pair_diversity_penalty = rerank._pair_diversity_penalty
|
|
||||||
|
|
||||||
|
|
||||||
def candidate(index, chunk_id, text, score):
|
def candidate(index, chunk_id, text, score):
|
||||||
return RerankCandidate(
|
return RerankCandidate(
|
||||||
index=index,
|
index=index,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue