Skip to content

usedatabrew/open_ai_benthos_processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open AI Processor for Benthos

Benthos processors are functions applied to messages passing through a pipeline. The function signature allows a processor to mutate or drop messages depending on the content of the message

Welcome to the Open AI Processor for Benthos! This processor allows you to enrich the context of your messages with requests to Open AI.

Getting Started

To get started you have to run benthos with custom processor. Since this processor is not adopted by benthos itself you have to create a new benthos build with plugin registered

package main

import (
    "context"
    "github.com/benthosdev/benthos/v4/public/service"

    _ "github.com/benthosdev/benthos/v4/public/components/all"
    // import open_ai processor
    _ "github.com/usedatabrew/open_ai_benthos_processor"
)

func main() {
	// here we initialize benthos
	service.RunCLI(context.Background())
}

Create benthos configuration with processor

pipeline:
  label: open_ai_processor
  processors:
    - open_ai:
        source_field: "comment"
        target_field: "ai_processed_comment"
        prompt: "Check the field for hateful speech"
        api_key: ""
        api_endpoint: "" ## Optional for azure driver
        driver: "azure" ## azure or openai
        model: "gpt-3.5-turbo-instruct"