Pipeline
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-pipeline"# 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-pipeline"# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO pip install --extra-index-url "gllm-pipeline"Quickstart
1
2
3
Define your steps
def to_upper(data: dict) -> str:
return data["text"].upper()
def count_chars(data: dict) -> int:
return len(data["text_upper"])
pipe = Pipeline(
steps=[
transform(to_upper, input_states=["text"], output_state="text_upper"),
transform(count_chars, input_states=["text_upper"], output_state="text_len"),
bundle(["text", "text_upper", "text_len"], output_state="summary"),
],
state_type=MiniState,
)4
Invoke the pipeline
import asyncio
initial: MiniState = {
"text": "hello world",
"text_upper": "",
"text_len": 0,
"summary": {},
}
final = asyncio.run(pipe.invoke(initial))
print(final){'text': 'hello world', 'text_upper': 'HELLO WORLD', 'text_len': 11,
'summary': {'text': 'hello world', 'text_upper': 'HELLO WORLD', 'text_len': 11}}The Pipe Operator
Appending a Step
Merge Two Pipelines
Placeholder Pipelines
Visualizing the Pipeline
Runtime Configuration
Using the Debug State
Using a Pipeline as a Subgraph
Using the Leftshift (<<) Operator
Last updated
Was this helpful?