event

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 6 Imported by: 0

README

SlackGPT

Slack bot for generating chats or text completions using OpenAI's range of models.

SlackGPT is built on top of Slack Bot Users for bot interactions and messages, OpenAI APIs for AI text completion, and GCP for sewing everything together, notably Cloud Functions and Pub/Sub.

SlackGPT can be direct messaged privately if you need a listening ear, or added to a channel for a team's worth of fun.

Usage

There's 2 ways of running SlackGPT. Firstly through GCP using Cloud Functions and PubSub, this is the preferred method as Cloud Functions can manage scaling for you and be generally cheaper, and PubSub also helps handle error correction and retry for generation. The other option is to run in socket mode which is also useful for testing purposes.

Either way, you'll need to ensure you have the following resources:

PubSub mode

Create generating function from pubsub.go;PubSubGenerate

This function should be triggered from pubsub topic push and should have the following env vars set:

OPENAI_TOKEN=(OpenAI API Key)
SLACK_BOT_TOKEN=(Slack Bot token)
MODEL=(Optional. Model for text generation. Defaults to "gpt-3.5-turbo")

Create slack event receiver function from event.go;SlackEvent

This function should be triggered from HTTP, provide the trigger URL to Slack event subscriptions and should have the following env vars set:

SLACK_SINGING_SECRET=(Signing Secret from Slack app)
PROJECT_ID=(GCP Project ID)
PUBSUB_TOPIC=(GCP PubSub Topic)
Socket mode

Set the following env vars:

export OPENAI_TOKEN=(Slack API Key)
export SLACK_APP_TOKEN=(Slack App Token)
export SLACK_BOT_TOKEN=(Slack Bot Token)
export MODEL=(Optional. Model for text generation. Defaults to "gpt-3.5-turbo")

Run socket mode application:

go run cmd/socket/main.go

Enable socket mode in Slack app settings

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PubSubGenerate

func PubSubGenerate(ctx context.Context, m pubsub.PubSubMessage) error

func SlackEvent

func SlackEvent(w http.ResponseWriter, r *http.Request)

Types

This section is empty.

Directories

Path Synopsis
cmd
internal
web
pkg
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL