Skip to content

Commit

Permalink
hack: update instructions and use latest gpt4 model (#23)
Browse files Browse the repository at this point in the history
* hack: update instructions and use latest gpt4 model

* internal: set assistant temp to 0.1

This will give us more deterministic and less fictional responses.
  • Loading branch information
vaijab authored Apr 26, 2024
1 parent 8dbce71 commit da4f4de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/muesli/reflow v0.3.0
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.16.0
github.com/sashabaranov/go-openai v1.19.4
github.com/sashabaranov/go-openai v1.23.0
github.com/sirupsen/logrus v1.9.3
github.com/slack-go/slack v0.12.2
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,8 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo=
github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U=
github.com/sashabaranov/go-openai v1.19.4 h1:GbaDiqvgYCabyqzuIbcEeT6/ZX1nVfur+++oTBfOgks=
github.com/sashabaranov/go-openai v1.19.4/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/sashabaranov/go-openai v1.23.0 h1:KYW97r5yc35PI2MxeLZ3OofecB/6H+yxvSNqiT9u8is=
github.com/sashabaranov/go-openai v1.23.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
Expand Down
14 changes: 7 additions & 7 deletions hack/openai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ func main() {
}

func updateAssistant(ctx context.Context, c *openai.Client, id string) (openai.Assistant, error) {
instructions := heredoc.Doc(`
Your role involves deeply understanding how to operate and troubleshoot Kubernetes clusters and their workloads.
You possess extensive expertise in Kubernetes and cloud-native networking.
Employ a Chain of Thought (CoT) process for diagnosing and resolving cluster issues.
Ensure your explanations are simplified for clarity to non-technical users.
Utilize available tools for diagnosing the specific cluster in question. Focus your responses to be concise and relevant.`)
instructions := heredoc.Doc(`Your role involves deeply understanding how to operate and troubleshoot Kubernetes clusters and their workloads.
You possess extensive expertise in Kubernetes and cloud-native networking. Take kubernetes cluster and namespace configuration, such as security policies, events, during troubleshooting.
Employ a Chain of Thought (CoT) process for diagnosing and resolving cluster issues.
Ensure your explanations are simplified for clarity to non-technical users.
Utilize available tools for diagnosing the specific cluster in question. Focus your responses to be concise and relevant.
Keep responses concise, within 2000 characters. Provide extended answers only upon request.`)

return c.ModifyAssistant(ctx, id, openai.AssistantRequest{
Model: openai.GPT4TurboPreview,
Model: openai.GPT4Turbo,
Instructions: &instructions,
Tools: openAITools,
})
Expand Down
3 changes: 3 additions & 0 deletions internal/source/ai-brain/assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
serviceName = "botkube-plugins-source-ai-brain"
)

var temperature float32 = 0.1

type tool func(ctx context.Context, args []byte) (string, error)

// Payload represents incoming webhook payload.
Expand Down Expand Up @@ -170,6 +172,7 @@ func (i *assistant) handleThread(ctx context.Context, p *Payload) (err error) {
log.Info("created a new assistant run")
run, err := i.openaiClient.CreateRun(ctx, threadID, openai.RunRequest{
AssistantID: i.assistID,
Temperature: &temperature,
})
if err != nil {
return fmt.Errorf("while creating a thread run: %w", err)
Expand Down

0 comments on commit da4f4de

Please sign in to comment.