Parser Router
Installation
# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc"# you can use a Conda environment
$token = (gcloud auth print-access-token)
pip install --extra-index-url "https://oauth2accesstoken:$token@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-docproc"# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO SET TOKEN=%T
pip install --extra-index-url "https://oauth2accesstoken:%TOKEN%@glsdk.gdplabs.id/gen-ai-internaRunning the Router
1
from gllm_docproc.dpo_router.parser_router import ParserRouter
from gllm_docproc.model.parser_type import ParserType
# Example source: path to loaded elements JSON file
source = "./loaded_elements.json"
# Initialize ParserRouter
router = ParserRouter()
# Route the file to get the parser type
result = router.route(source)
# Access the detected parser type
print(f"Detected parser type: {result[ParserType.KEY]}")import json
from gllm_docproc.dpo_router.parser_router import ParserRouter
from gllm_docproc.model.parser_type import ParserType
# Load elements from JSON file into memory
with open("./loaded_elements.json", "r", encoding="utf-8") as f:
elements = json.load(f)
# Initialize ParserRouter
router = ParserRouter()
# Route the in-memory elements to get the parser type
result = router.route(elements)
# Access the detected parser type
print(f"Detected parser type: {result[ParserType.KEY]}")2
python main.py3
Detected parser type: pdf_parserLast updated
Was this helpful?