Skip to content

Commit

Permalink
Revert "adding llm_prompt helper"
Browse files Browse the repository at this point in the history
This reverts commit d1cf5ab.
  • Loading branch information
Mzack9999 committed Apr 4, 2023
1 parent d1cf5ab commit a9af941
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 42 deletions.
39 changes: 0 additions & 39 deletions dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"compress/gzip"
"compress/zlib"
"context"
"crypto/aes"
"crypto/cipher"
"crypto/hmac"
Expand All @@ -23,7 +22,6 @@ import (
"math"
"math/rand"
"net/url"
"os"
"regexp"
"sort"
"strconv"
Expand All @@ -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"
Expand Down Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit a9af941

Please sign in to comment.