Query Transformer
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-retrieval"# 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-retrieval"# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO pip install --extra-index-url "https://oauth2accesstoken:%T@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-retrieval"Quickstart
1
2
Create an LM request processor
lmrp = build_lm_request_processor(
model_id="openai/gpt-4.1-nano",
credentials="<your-api-key>", # or use the environment variable OPENAI_API_KEY
system_template="You are a helpful assistant that rewrites queries for better retrieval. Rewrite the following query. Only output the transformed query.",
user_template="Query: {query}", # 'query' will be supplied below (string or dict with matching keys)
)Extracting transformation result from structured output
Example 1: Extracting from JSON Output
Example 2: Extracting from Structured Output
Error handling
Last updated
Was this helpful?