Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LlmInfo and LlmInput from AI Guard #368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Redact: `Unredact()` method on service interface.
- Redact: `FPEContext` on `RedactResult` and `StructuredResult`.

### Removed

- AI Guard: `LlmInfo` and `LlmInput`.

## 4.4.0 - 2025-02-16

### Added
Expand Down
6 changes: 2 additions & 4 deletions pangea-sdk/service/ai_guard/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
// input := &ai_guard.TextGuardRequest{Text: "hello world"}
// response, err := client.GuardText(ctx, input)
func (e *aiGuard) GuardText(ctx context.Context, input *TextGuardRequest) (*pangea.PangeaResponse[TextGuardResult], error) {
if input.Text == "" && input.Messages == nil && input.LlmInput == nil {
return nil, errors.New("one of `text`, `messages`, or `llm_input` must be defined")
if input.Text == "" && input.Messages == nil {
return nil, errors.New("one of `Text` or `Messages` must be defined")
}

return request.DoPost(ctx, e.Client, "v1/text/guard", input, &TextGuardResult{})
Expand Down Expand Up @@ -110,10 +110,8 @@ type TextGuardRequest struct {

Text string `json:"text,omitempty"` // Text to be scanned by AI Guard for PII, sensitive data, malicious content, and other data types defined by the configuration. Supports processing up to 10KB of text.
Messages any `json:"messages,omitempty"` // Structured messages data to be scanned by AI Guard for PII, sensitive data, malicious content, and other data types defined by the configuration. Supports processing up to 10KB of JSON text.
LlmInput any `json:"llm_input,omitempty"` // Structured full llm payload data to be scanned by AI Guard for PII, sensitive data, malicious content, and other data types defined by the configuration. Supports processing up to 10KB of JSON text.
Recipe string `json:"recipe,omitempty"` // Recipe key of a configuration of data types and settings defined in the Pangea User Console. It specifies the rules that are to be applied to the text, such as defang malicious URLs.
Debug bool `json:"debug,omitempty"` // Setting this value to true will provide a detailed analysis of the text data
LlmInfo string `json:"llm_info,omitempty"` // Short string hint for the LLM Provider information
LogFields LogFields `json:"log_fields,omitempty"` // Additional fields to include in activity log
}

Expand Down
21 changes: 0 additions & 21 deletions pangea-sdk/service/ai_guard/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,3 @@ func TestTextGuard_Messages(t *testing.T) {
assert.NotNil(t, out.Result)
assert.NotNil(t, out.Result.PromptMessages)
}

func TestTextGuard_Llm_Input(t *testing.T) {
ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
defer cancelFn()

client := ai_guard.New(pangeatesting.IntegrationConfig(t, testingEnvironment))

input := &ai_guard.TextGuardRequest{LlmInput: map[string]interface{}{
"model": "gpt-4o",
"messages": []map[string]interface{}{
{
"role": "user",
"content": "what was pangea?",
},
},
}}
out, err := client.GuardText(ctx, input)
assert.NoError(t, err)
assert.NotNil(t, out.Result)
assert.NotNil(t, out.Result.PromptMessages)
}