You've already forked grok
more sophisticated prompting
This commit is contained in:
46
main.go
46
main.go
@@ -28,18 +28,52 @@ func (p *OpenAIPrompter) Prompt(ctx context.Context, req PromptRequest) (*Highly
|
||||
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)
|
||||
input := []responses.ResponseInputItemUnionParam{
|
||||
{
|
||||
OfMessage: &responses.EasyInputMessageParam{
|
||||
Content: responses.EasyInputMessageContentUnionParam{
|
||||
OfString: openai.String(p.cfg.SystemPrompt),
|
||||
},
|
||||
Role: responses.EasyInputMessageRoleSystem,
|
||||
},
|
||||
},
|
||||
{
|
||||
OfMessage: &responses.EasyInputMessageParam{
|
||||
Content: responses.EasyInputMessageContentUnionParam{
|
||||
OfString: openai.String("Пользователя зовут " + req.Username),
|
||||
},
|
||||
Role: responses.EasyInputMessageRoleSystem,
|
||||
},
|
||||
},
|
||||
{
|
||||
OfMessage: &responses.EasyInputMessageParam{
|
||||
Content: responses.EasyInputMessageContentUnionParam{
|
||||
OfString: openai.String(req.Question),
|
||||
},
|
||||
Role: responses.EasyInputMessageRoleUser,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
prompt := fmt.Sprintf("<system>%v</system> user %v asks: %v", instructions, req.Username, req.Question)
|
||||
p.log.Info("resulting prompt", "prompt", prompt)
|
||||
if req.OriginalPostContent != nil {
|
||||
message := "Пользователь может ссылаться на текст поста, который он комментирует. Вот он: " +
|
||||
*req.OriginalPostContent
|
||||
|
||||
input = append(input, responses.ResponseInputItemUnionParam{
|
||||
OfMessage: &responses.EasyInputMessageParam{
|
||||
Content: responses.EasyInputMessageContentUnionParam{
|
||||
OfString: openai.String(message),
|
||||
},
|
||||
Role: responses.EasyInputMessageRoleDeveloper,
|
||||
Type: responses.EasyInputMessageTypeMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := p.cli.Responses.New(ctx, responses.ResponseNewParams{
|
||||
Instructions: openai.String(p.cfg.SystemPrompt),
|
||||
Input: responses.ResponseNewParamsInputUnion{
|
||||
OfString: openai.String(prompt),
|
||||
OfInputItemList: input,
|
||||
},
|
||||
Reasoning: shared.ReasoningParam{
|
||||
Effort: shared.ReasoningEffortXhigh,
|
||||
|
||||
Reference in New Issue
Block a user