You've already forked grok
send instructions in user prompt
This commit is contained in:
13
main.go
13
main.go
@@ -31,13 +31,15 @@ func (p *OpenAIPrompter) Prompt(ctx context.Context, req PromptRequest) (*Highly
|
||||
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)
|
||||
}
|
||||
|
||||
prompt := fmt.Sprintf("<system>%v</system> user %v asks: %v", instructions, req.Username, req.Question)
|
||||
p.log.Info("resulting prompt", "prompt", prompt)
|
||||
|
||||
resp, err := p.cli.Responses.New(ctx, responses.ResponseNewParams{
|
||||
Instructions: openai.String(p.cfg.SystemPrompt),
|
||||
Input: responses.ResponseNewParamsInputUnion{
|
||||
OfString: openai.String(req.Question),
|
||||
OfString: openai.String(prompt),
|
||||
},
|
||||
Reasoning: shared.ReasoningParam{
|
||||
Effort: shared.ReasoningEffortXhigh,
|
||||
@@ -67,6 +69,7 @@ type HighlyTrustedResponse struct {
|
||||
}
|
||||
|
||||
type PromptRequest struct {
|
||||
Username string
|
||||
Question string
|
||||
OriginalPostContent *string
|
||||
}
|
||||
@@ -115,9 +118,15 @@ func (a *App) handleMessage(ctx context.Context, msg *tgbotapi.Message) error {
|
||||
ogPostContent = &msg.ReplyToMessage.Text
|
||||
}
|
||||
|
||||
var username string
|
||||
if msg.From != nil {
|
||||
username = msg.From.UserName
|
||||
}
|
||||
|
||||
response, err := a.proompter.Prompt(ctx, PromptRequest{
|
||||
Question: question,
|
||||
OriginalPostContent: ogPostContent,
|
||||
Username: username,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("prompting: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user