You've already forked grok
finally?
This commit is contained in:
12
main.go
12
main.go
@@ -21,12 +21,17 @@ import (
|
||||
type OpenAIPrompter struct {
|
||||
cli openai.Client
|
||||
cfg *Config
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
func (p *OpenAIPrompter) Prompt(ctx context.Context, req PromptRequest) (*HighlyTrustedResponse, error) {
|
||||
p.log.Info("new prompt request",
|
||||
"req", req)
|
||||
|
||||
instructions := p.cfg.SystemPrompt
|
||||
if req.OriginalPostContent != nil {
|
||||
instructions += fmt.Sprintf("\nThis is the channel post that user is mentioning: %s", *req.OriginalPostContent)
|
||||
p.log.Info("composed instructions with post", "instructions", instructions)
|
||||
}
|
||||
|
||||
resp, err := p.cli.Responses.New(ctx, responses.ResponseNewParams{
|
||||
@@ -47,12 +52,13 @@ func (p *OpenAIPrompter) Prompt(ctx context.Context, req PromptRequest) (*Highly
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewOpenAIProoooompter(cfg *Config) *OpenAIPrompter {
|
||||
func NewOpenAIProoooompter(cfg *Config, log *slog.Logger) *OpenAIPrompter {
|
||||
return &OpenAIPrompter{
|
||||
cli: openai.NewClient(
|
||||
option.WithBaseURL(cfg.OpenAIBaseURL),
|
||||
),
|
||||
cfg: cfg,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +110,7 @@ func (a *App) handleMessage(ctx context.Context, msg *tgbotapi.Message) error {
|
||||
)
|
||||
|
||||
var ogPostContent *string
|
||||
if msg.ReplyToMessage.From.ID == a.config.ChannelID {
|
||||
if msg.ReplyToMessage != nil && msg.ReplyToMessage.SenderChat.ID == a.config.ChannelID {
|
||||
a.log.Info("message was a reply to channel post")
|
||||
ogPostContent = &msg.ReplyToMessage.Text
|
||||
}
|
||||
@@ -250,7 +256,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
prompter := NewOpenAIProoooompter(&cfg)
|
||||
prompter := NewOpenAIProoooompter(&cfg, log)
|
||||
|
||||
app, err := NewApp(&cfg, prompter)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user