Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.
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
1 change: 1 addition & 0 deletions .github/workflows/javascript-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
CHROMA_COLLECTION_NAME: javascript_tests
run: |
npm install
npm run build
npm test

- name: Dump docker logs
Expand Down
18 changes: 2 additions & 16 deletions javascript-sdk/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,15 @@ export default class RebuffApi implements Rebuff {

async detectInjection({
userInput = "",
maxHeuristicScore = 0.75,
maxVectorScore = 0.9,
maxModelScore = 0.9,
runHeuristicCheck = true,
runVectorCheck = true,
runLanguageModelCheck = true,
tacticOverrides = [],
}: DetectRequest): Promise<DetectResponse> {
if (userInput === null) {
throw new RebuffError("userInput is required");
}
const requestData: DetectRequest = {
userInput: "",
userInputBase64: encodeString(userInput),
runHeuristicCheck: runHeuristicCheck,
runVectorCheck: runVectorCheck,
runLanguageModelCheck: runLanguageModelCheck,
maxVectorScore,
maxModelScore,
maxHeuristicScore,
tacticOverrides,
};

const response = await fetch(`${this.apiUrl}/api/detect`, {
Expand All @@ -76,10 +66,6 @@ export default class RebuffApi implements Rebuff {
if (!response.ok) {
throw new RebuffError((responseData as any)?.message);
}
responseData.injectionDetected =
responseData.heuristicScore > maxHeuristicScore ||
responseData.modelScore > maxModelScore ||
responseData.vectorScore.topScore > maxVectorScore;
return responseData;
}

Expand Down