Pipelines

A pipeline is a manifest of topics and processing steps.

The example manifest below defines a pipeline with 1 step. It receives messages via "input-topic", processes the messages with the ai-chat-completions agent, and sends the processed messages to "output-topic".

topics:
  - name: "input-topic"
    creation-mode: create-if-not-exists
  - name: "output-topic"
    creation-mode: create-if-not-exists
errors:
  on-failure: skip
pipeline:
  - name: "ai-chat-completions"
    type: "ai-chat-completions"
    input: "input-topic"
    configuration:
      model: "gpt-3.5-turbo"
      completion-field: "value"
      messages:
        - role: user
          content: "What can you tell me about {{ value}} ?"

Pipeline configuration

Pipeline agents configuration

Inside the pipeline property, you must specify a list of agents.

Each agent can be configured with the following properties.

Agent resources

When deploying a pipeline, some agents might require additional CPU or memory to run properly. Depending on the traffic load and the agent architecture, you might need to scale the pipeline vertically or horizontally, or both.

The resources property allows you to specify the size (scale vertically) and the parallelism (scale horizontally) for the pipeline.

topics:
  ...

resources:
  parallelism: 3
  size: 2
  
pipeline:
  ...

Setting parallelism to 3 will deploy the pipeline with 3 different replicas. Each replica will use the configured size for CPU and memory.

The size parameter describes both CPU and memory. The value is a multiplier factor that is computed at runtime, starting from a base cpu/memory value. For example, if the default value for the memory - for a single replica - is 512 MB, specifying size: 2 will make the pipeline to use 1024MB per-replica.

The requested resources are implemented by using Kubernetes limits. Be aware that if an agent tries to use more memory than the requested, the pipeline will fail with OOMKilled error.

Multiple manifests in one application

When you place multiple yaml manifests in the same "application" folder, LangStream will create a single application with multiple modules. Each module is a pipeline of agent steps.

|- project-folder
    |- application
        |- pipeline.yaml
        |- second-pipeline.yaml
        |- gateways.yaml
        |- configuration.yaml

In this structure, both pipeline.yaml and second-pipeline.yaml will be created as a single application, with a separate module for each pipeline.

See the webcrawler pipeline agent and its source code for an example.

Last updated