Skip to content

Commit

Permalink
feat: allow system message
Browse files Browse the repository at this point in the history
  • Loading branch information
fandujar committed Oct 18, 2024
1 parent 4ff2685 commit fb355a0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pkg/transport/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package transport

import (
"encoding/json"
"os"

"github.com/fandujar/baymax/pkg/plugins"
"github.com/fandujar/baymax/pkg/services"
Expand Down Expand Up @@ -37,19 +38,16 @@ func (h *OpenAIHandler) RunEventLoop() {
}

messages := []openai.ChatCompletionMessage{}
systemMessage := openai.ChatCompletionMessage{
Role: "system",
Content: `You are a helpful and structured assistant. Please ensure to format your response using Slack markdown:
- Use *bold* for important information.
- Use _italic_ for emphasis.
- Use monospace (` + "`" + `) for code or unique values.
- Structure your responses clearly.

Respond concisely. Avoid excessive jargon, bullet points, and unnecessary technical terms.`,
systemMessage := os.Getenv("OPENAI_SYSTEM_MESSAGE")
log.Debug().Str("system_message", systemMessage).Msg("system message")
if systemMessage != "" {
messages = append(messages, openai.ChatCompletionMessage{
Role: "system",
Content: systemMessage,
})
}

messages = append(messages, systemMessage)

for _, message := range ev.Messages {
messages = append(messages, openai.ChatCompletionMessage{
Role: "user",
Expand Down

0 comments on commit fb355a0

Please sign in to comment.