ollama
Processes data through an Ollama instance
Description
This processor runs provided records through a specified model on a provided Ollama instance. It uses the provided prompt to transform the incoming records.
Configuration parameters
- YAML
 - Table
 
version: 2.2
pipelines:
  - id: example
    status: running
    connectors:
      # define source and destination ...
    processors:
      - id: example
        plugin: "ollama"
        settings:
          # Field is the reference to the field to process. Defaults to
          # ".Payload.After".
          # Type: string
          field: ".Payload.After"
          # Model is the name of the model used with ollama
          # Type: string
          model: "llama3.2"
          # Prompt is the prompt to pass into ollama to tranform the data
          # Type: string
          prompt: ""
          # Whether to decode the record key using its corresponding schema from
          # the schema registry.
          # Type: bool
          sdk.schema.decode.key.enabled: "true"
          # Whether to decode the record payload using its corresponding schema
          # from the schema registry.
          # Type: bool
          sdk.schema.decode.payload.enabled: "true"
          # Whether to encode the record key using its corresponding schema from
          # the schema registry.
          # Type: bool
          sdk.schema.encode.key.enabled: "true"
          # Whether to encode the record payload using its corresponding schema
          # from the schema registry.
          # Type: bool
          sdk.schema.encode.payload.enabled: "true"
          # OllamaURL is the url to the ollama instance
          # Type: string
          url: ""
| Name | Type | Default | Description | 
|---|---|---|---|
field | string | .Payload.After | Field is the reference to the field to process. Defaults to ".Payload.After".  | 
model | string | llama3.2 | Model is the name of the model used with ollama  | 
prompt | string | null  | Prompt is the prompt to pass into ollama to tranform the data  | 
sdk.schema.decode.key.enabled | bool | true | Whether to decode the record key using its corresponding schema from the schema registry.  | 
sdk.schema.decode.payload.enabled | bool | true | Whether to decode the record payload using its corresponding schema from the schema registry.  | 
sdk.schema.encode.key.enabled | bool | true | Whether to encode the record key using its corresponding schema from the schema registry.  | 
sdk.schema.encode.payload.enabled | bool | true | Whether to encode the record payload using its corresponding schema from the schema registry.  | 
url | string | null  | OllamaURL is the url to the ollama instance  | 
Examples
Ollama Prompt Example
This example will process the record stored in
.Payload.After. The model is prompted to return the records unchanged.
The records are returned as a JSON with the same format as the data.
Configuration parameters
- YAML
 - Table
 
version: 2.2
pipelines:
  - id: example
    status: running
    connectors:
      # define source and destination ...
    processors:
      - id: example
        plugin: "ollama"
        settings:
          field: ".Payload.After"
          model: "llama3.2"
          prompt: "Take the incoming record in JSON format, with a structure of {'test-field': integer}. Add one to the value of the integer and return that field."
          url: "http://localhost:11434"
| Name | Value | 
|---|---|
field | .Payload.After | 
model | llama3.2 | 
prompt | Take the incoming record in JSON format, with a structure of {'test-field': integer}. Add one to the value of the integer and return that field. | 
url | http://localhost:11434 | 
Record difference
Before  | After  | ||||
1  | { | 1  | { | ||
2  | "position": "dGVzdC1wb3NpdGlvbg==",  | 2  | "position": "dGVzdC1wb3NpdGlvbg==",  | ||
3  | "operation": "create",  | 3  | "operation": "create",  | ||
4  |   "metadata": { | 4  |   "metadata": { | ||
5  | "key1": "val1"  | 5  | "key1": "val1"  | ||
6  | },  | 6  | },  | ||
7  | "key": "test-key",  | 7  | "key": "test-key",  | ||
8  |   "payload": { | 8  |   "payload": { | ||
9  | "before": null,  | 9  | "before": null,  | ||
10  |     "after": { | 10  |     "after": { | ||
11  | -  | "test-field": 123  | 11  | +  | "test-field": 124  | 
12  | }  | 12  | }  | ||
13  | }  | 13  | }  | ||
14  | }  | 14  | }  | ||
