Fix one-argument-per-line style in prompt injection guardrail
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
committed by
Sacha Al Himdani
parent
ded859d130
commit
2f8674471b
@@ -56,7 +56,9 @@ func (g *PromptInjectionGuardrail) Check(ctx context.Context, messages []llm.Mes
|
|||||||
return &agent.GuardrailResult{Tripwire: false}, nil
|
return &agent.GuardrailResult{Tripwire: false}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := g.client.ChatCompletion(ctx, &llm.ChatCompletionRequest{
|
resp, err := g.client.ChatCompletion(
|
||||||
|
ctx,
|
||||||
|
&llm.ChatCompletionRequest{
|
||||||
Model: "gpt-4o-mini",
|
Model: "gpt-4o-mini",
|
||||||
Messages: []llm.Message{
|
Messages: []llm.Message{
|
||||||
{
|
{
|
||||||
@@ -70,12 +72,15 @@ func (g *PromptInjectionGuardrail) Check(ctx context.Context, messages []llm.Mes
|
|||||||
},
|
},
|
||||||
MaxTokens: new(10),
|
MaxTokens: new(10),
|
||||||
Temperature: new(0.0),
|
Temperature: new(0.0),
|
||||||
})
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the classifier fails, allow the message through rather than
|
// If the classifier fails, allow the message through rather than
|
||||||
// blocking legitimate users. The system prompt hardening and
|
// blocking legitimate users. The system prompt hardening and
|
||||||
// tool-level authorization provide defense in depth.
|
// tool-level authorization provide defense in depth.
|
||||||
g.logger.WarnCtx(ctx, "prompt injection classifier failed, allowing message through",
|
g.logger.WarnCtx(
|
||||||
|
ctx,
|
||||||
|
"prompt injection classifier failed, allowing message through",
|
||||||
log.Error(err),
|
log.Error(err),
|
||||||
)
|
)
|
||||||
return &agent.GuardrailResult{Tripwire: false}, nil
|
return &agent.GuardrailResult{Tripwire: false}, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user