Use newer model cause Discord be bussin'
This commit is contained in:
parent
2732420294
commit
6b8f4674c3
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
.git
|
||||
*.md
|
||||
*.log
|
||||
Dockerfile
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM golang:latest AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Build static binary
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o discord-gpt-bot main.go
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# ✅ Install CA certs
|
||||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/discord-gpt-bot .
|
||||
|
||||
CMD ["./discord-gpt-bot"]
|
||||
|
@ -3,8 +3,8 @@ package bot
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.ewnix.net/phlux/discord-gpt-bot/bot/memory"
|
||||
"git.ewnix.net/phlux/discord-gpt-bot/openai"
|
||||
"discord-gpt-bot/openai"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@ func Start(session *discordgo.Session) {
|
||||
|
||||
userID := m.Author.ID
|
||||
content := strings.ReplaceAll(m.Content, "<@"+s.State.User.ID+">", "")
|
||||
history := memory.GetHistory(userID)
|
||||
history := GetHistory(userID)
|
||||
|
||||
history = append(history, openai.Message{Role: "user", Content: strings.TrimSpace(content)})
|
||||
resp, err := openai.Ask(history)
|
||||
@ -30,7 +30,7 @@ func Start(session *discordgo.Session) {
|
||||
}
|
||||
|
||||
history = append(history, openai.Message{Role: "assistant", Content: resp})
|
||||
memory.SetHistory(userID, history)
|
||||
SetHistory(userID, history)
|
||||
|
||||
s.ChannelMessageSend(m.ChannelID, resp)
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
package memory
|
||||
package bot
|
||||
|
||||
import (
|
||||
"git.ewnix.net/phlux/discord-gpt-bot/openai"
|
||||
"discord-gpt-bot/openai"
|
||||
)
|
||||
|
||||
var conversations = map[string][]openai.Message{}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @TODO: We really need to get more options in here such as ignore, message lengths, etc.
|
||||
package config
|
||||
|
||||
var (
|
||||
|
9
go.mod
9
go.mod
@ -1,11 +1,14 @@
|
||||
module git.ewnix.net/phlux/discord-gpt-bot
|
||||
module discord-gpt-bot
|
||||
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.28.1 // indirect
|
||||
github.com/bwmarrin/discordgo v0.28.1
|
||||
github.com/sashabaranov/go-openai v1.38.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/sashabaranov/go-openai v1.38.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
|
||||
)
|
||||
|
5
main.go
5
main.go
@ -6,8 +6,9 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"git.ewnix.net/phlux/discord-gpt-bot/bot"
|
||||
"git.ewnix.net/phlux/discord-gpt-bot/config"
|
||||
"discord-gpt-bot/bot"
|
||||
"discord-gpt-bot/config"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
|
@ -3,7 +3,8 @@ package openai
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.ewnix.net/phlux/g/discord-gpt-bot/config"
|
||||
"discord-gpt-bot/config"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
@ -26,8 +27,9 @@ func Ask(messages []Message) (string, error) {
|
||||
resp, err := client.CreateChatCompletion(
|
||||
context.Background(),
|
||||
openai.ChatCompletionRequest{
|
||||
Model: openai.GPT4,
|
||||
Messages: chatHistory,
|
||||
Model: "gpt-4.1",
|
||||
Messages: chatHistory,
|
||||
MaxTokens: 600,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user