Skip to content

Commit dd256da

Browse files
author
waleed
committed
cleanup
1 parent c9f9d90 commit dd256da

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

apps/sim/app/api/guardrails/validate/route.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ async function executeValidation(
212212
}
213213
}
214214

215-
// Use TypeScript hallucination validator with RAG + LLM scoring
216215
return await validateHallucination({
217216
userInput: inputStr,
218217
knowledgeBaseId,
@@ -225,7 +224,6 @@ async function executeValidation(
225224
})
226225
}
227226
if (validationType === 'pii') {
228-
// PII validation using Presidio
229227
return await validatePII({
230228
text: inputStr,
231229
entityTypes: piiEntityTypes || [], // Empty array = detect all PII types

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/grouped-checkbox-list.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ export function GroupedCheckboxList({
3939
const [open, setOpen] = useState(false)
4040
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlockId)
4141

42-
// Get preview value or use store value
4342
const previewValue = isPreview && subBlockValues ? subBlockValues[subBlockId]?.value : undefined
4443
const selectedValues = ((isPreview ? previewValue : storeValue) as string[]) || []
4544

46-
// Group options by their group property
4745
const groupedOptions = useMemo(() => {
4846
const groups: Record<string, { label: string; id: string }[]> = {}
4947

apps/sim/lib/guardrails/validate_hallucination.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from '@/lib/env'
12
import { createLogger } from '@/lib/logs/console/logger'
23
import { executeProviderRequest } from '@/providers'
34
import { getApiKey, getProviderFromModel } from '@/providers/utils'
@@ -40,7 +41,7 @@ async function queryKnowledgeBase(
4041
})
4142

4243
// Call the knowledge base search API directly
43-
const searchUrl = `${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/api/knowledge/search`
44+
const searchUrl = `${env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/api/knowledge/search`
4445

4546
const response = await fetch(searchUrl, {
4647
method: 'POST',
@@ -65,7 +66,6 @@ async function queryKnowledgeBase(
6566
const result = await response.json()
6667
const results = result.data?.results || []
6768

68-
// Extract content from search results
6969
const chunks = results.map((r: any) => r.content || '').filter((c: string) => c.length > 0)
7070

7171
logger.info(`[${requestId}] Retrieved ${chunks.length} chunks from knowledge base`)
@@ -140,18 +140,15 @@ Evaluate the consistency and provide your score and reasoning in JSON format.`
140140
apiKey,
141141
})
142142

143-
// Handle streaming response (shouldn't happen with our request, but just in case)
144143
if (response instanceof ReadableStream || ('stream' in response && 'execution' in response)) {
145144
throw new Error('Unexpected streaming response from LLM')
146145
}
147146

148147
const content = response.content.trim()
149148
logger.debug(`[${requestId}] LLM response:`, { content })
150149

151-
// Try to parse JSON from the response
152150
let jsonContent = content
153151

154-
// Remove markdown code blocks if present
155152
if (content.includes('```')) {
156153
const jsonMatch = content.match(/```(?:json)?\s*(\{[\s\S]*?\})\s*```/)
157154
if (jsonMatch) {
@@ -191,7 +188,6 @@ export async function validateHallucination(
191188
input
192189

193190
try {
194-
// Validate inputs
195191
if (!userInput || userInput.trim().length === 0) {
196192
return {
197193
passed: false,
@@ -206,7 +202,6 @@ export async function validateHallucination(
206202
}
207203
}
208204

209-
// Get API key for the model
210205
let finalApiKey: string
211206
try {
212207
const providerId = getProviderFromModel(model)
@@ -248,8 +243,7 @@ export async function validateHallucination(
248243
threshold,
249244
})
250245

251-
// Step 3: Check against threshold
252-
// Lower scores = less confidence = fail validation
246+
// Step 3: Check against threshold. Lower scores = less confidence = fail validation
253247
const passed = score >= threshold
254248

255249
return {

apps/sim/tools/guardrails/validate.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,8 @@ export const guardrailsValidateTool: ToolConfig<GuardrailsValidateInput, Guardra
164164
},
165165

166166
transformResponse: async (response: Response): Promise<GuardrailsValidateOutput> => {
167-
// Always parse the JSON response, even for non-OK status codes
168-
// Our API always returns a structured response with validation results
169167
const result = await response.json()
170168

171-
// If the API returned an error structure (shouldn't happen now, but just in case)
172169
if (!response.ok && !result.output) {
173170
return {
174171
success: true,

0 commit comments

Comments
 (0)