From a9af9413e36a8bd6da148ffa6babdb5e15d788f2 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Tue, 4 Apr 2023 15:12:48 +0800 Subject: [PATCH] Revert "adding llm_prompt helper" This reverts commit d1cf5ab26f9d9b862ad10e53e9503e3738629f7e. --- dsl.go | 39 --------------------------------------- go.mod | 1 - go.sum | 2 -- 3 files changed, 42 deletions(-) diff --git a/dsl.go b/dsl.go index 2e77586..88bf1d8 100644 --- a/dsl.go +++ b/dsl.go @@ -4,7 +4,6 @@ import ( "bytes" "compress/gzip" "compress/zlib" - "context" "crypto/aes" "crypto/cipher" "crypto/hmac" @@ -23,7 +22,6 @@ import ( "math" "math/rand" "net/url" - "os" "regexp" "sort" "strconv" @@ -36,7 +34,6 @@ import ( "github.com/kataras/jwt" "github.com/logrusorgru/aurora" "github.com/pkg/errors" - "github.com/sashabaranov/go-openai" "github.com/spaolacci/murmur3" "github.com/projectdiscovery/dsl/deserialization" @@ -973,42 +970,6 @@ func init() { } return formattedIps[0], nil }), - "llm_prompt": makeDslFunction(1, func(args ...interface{}) (interface{}, error) { - prompt := args[0].(string) - - openaiToken := os.Getenv("OPENAI_TOKEN") - - if openaiToken == "" { - return nil, errors.New("no token defined") - } - - client := openai.NewClient(openaiToken) - - resp, err := client.CreateChatCompletion( - context.Background(), - openai.ChatCompletionRequest{ - Model: openai.GPT3Dot5Turbo, - Messages: []openai.ChatCompletionMessage{ - { - Role: openai.ChatMessageRoleUser, - Content: prompt, - }, - }, - }, - ) - - if err != nil { - return nil, err - } - - if len(resp.Choices) == 0 { - return nil, errors.New("no data") - } - - data := resp.Choices[0].Message.Content - - return data, nil - }), } dslFunctions = make(map[string]dslFunction, len(tempDslFunctions)) diff --git a/go.mod b/go.mod index 75b10f2..bb84bb1 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/projectdiscovery/blackrock v0.0.0-20230328171319-f24b18d05b64 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect - github.com/sashabaranov/go-openai v1.5.8 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect go.uber.org/multierr v1.10.0 // indirect diff --git a/go.sum b/go.sum index 4205164..4f5d958 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,6 @@ github.com/projectdiscovery/utils v0.0.18 h1:gyBMnA4y2ryui0G98iFqKAXuNdoSy6Z6K0/ github.com/projectdiscovery/utils v0.0.18/go.mod h1:Cu216AlQ7rAYa8aDBqB2OgNfu5p24Uj+tG9RxV8Wbfs= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= -github.com/sashabaranov/go-openai v1.5.8 h1:EfNEmc+Ue+CuRy7iSpNdxfHyiOv2vQsQ2Y0kZRA/z5w= -github.com/sashabaranov/go-openai v1.5.8/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=