-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(integrations): add Resemble Detect + Intelligence block #4925
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
Open
devshahofficial
wants to merge
3
commits into
simstudioai:main
Choose a base branch
from
devshahofficial:plugin/resemble-detect-intelligence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| import { ResembleIcon } from '@/components/icons' | ||
| import type { BlockConfig } from '@/blocks/types' | ||
| import { AuthMode, IntegrationType } from '@/blocks/types' | ||
| import type { ResembleResponse } from '@/tools/resemble/types' | ||
|
|
||
| export const ResembleBlock: BlockConfig<ResembleResponse> = { | ||
| type: 'resemble', | ||
| name: 'Resemble', | ||
| description: 'Deepfake detection, media intelligence, and watermarking', | ||
| longDescription: | ||
| 'Integrate Resemble AI media safety into your workflow: detect deepfakes in audio/image/video, analyze media intelligence, and apply or detect invisible watermarks.', | ||
| docsLink: 'https://docs.resemble.ai', | ||
| category: 'tools', | ||
| integrationType: IntegrationType.Security, | ||
| bgColor: '#2E1AC4', | ||
| icon: ResembleIcon, | ||
| authMode: AuthMode.ApiKey, | ||
|
|
||
| subBlocks: [ | ||
| { | ||
| id: 'operation', | ||
| title: 'Operation', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Deepfake Detection', id: 'resemble_detect' }, | ||
| { label: 'Media Intelligence', id: 'resemble_intelligence' }, | ||
| { label: 'Detect Watermark', id: 'resemble_watermark_detect' }, | ||
| { label: 'Apply Watermark', id: 'resemble_watermark_apply' }, | ||
| ], | ||
| value: () => 'resemble_detect', | ||
| }, | ||
| { | ||
| id: 'url', | ||
| title: 'Media URL', | ||
| type: 'short-input', | ||
| placeholder: 'https://example.com/media.mp4', | ||
| required: true, | ||
| }, | ||
| // Detection toggles | ||
| { | ||
| id: 'runIntelligence', | ||
| title: 'Run Intelligence', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'audioSourceTracing', | ||
| title: 'Audio Source Tracing', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'visualize', | ||
| title: 'Visualize', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'useReverseSearch', | ||
| title: 'Reverse Image Search', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'useOodDetector', | ||
| title: 'OOD Detector', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'zeroRetentionMode', | ||
| title: 'Zero-Retention Mode', | ||
| type: 'switch', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| { | ||
| id: 'modelTypes', | ||
| title: 'Model Type', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Auto', id: 'auto' }, | ||
| { label: 'Image', id: 'image' }, | ||
| { label: 'Talking Head', id: 'talking_head' }, | ||
| ], | ||
| value: () => 'auto', | ||
| condition: { field: 'operation', value: 'resemble_detect' }, | ||
| }, | ||
| // Intelligence options | ||
| { | ||
| id: 'structuredJson', | ||
| title: 'Structured JSON', | ||
| type: 'switch', | ||
| defaultValue: true, | ||
| condition: { field: 'operation', value: 'resemble_intelligence' }, | ||
| }, | ||
| { | ||
| id: 'mediaType', | ||
| title: 'Media Type', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Auto', id: 'auto' }, | ||
| { label: 'Audio', id: 'audio' }, | ||
| { label: 'Video', id: 'video' }, | ||
| { label: 'Image', id: 'image' }, | ||
| ], | ||
| value: () => 'auto', | ||
| condition: { field: 'operation', value: 'resemble_intelligence' }, | ||
| }, | ||
| // Apply-watermark options | ||
| { | ||
| id: 'strength', | ||
| title: 'Strength (0–1)', | ||
| type: 'short-input', | ||
| placeholder: '0.2', | ||
| condition: { field: 'operation', value: 'resemble_watermark_apply' }, | ||
| }, | ||
| { | ||
| id: 'customMessage', | ||
| title: 'Custom Message', | ||
| type: 'short-input', | ||
| placeholder: 'resembleai', | ||
| condition: { field: 'operation', value: 'resemble_watermark_apply' }, | ||
| }, | ||
| { | ||
| id: 'apiKey', | ||
| title: 'API Key', | ||
| type: 'short-input', | ||
| placeholder: 'Enter your Resemble API key', | ||
| required: true, | ||
| password: true, | ||
| }, | ||
| ], | ||
|
|
||
| tools: { | ||
| access: [ | ||
| 'resemble_detect', | ||
| 'resemble_intelligence', | ||
| 'resemble_watermark_detect', | ||
| 'resemble_watermark_apply', | ||
| ], | ||
| config: { | ||
| tool: (params) => { | ||
| switch (params.operation) { | ||
| case 'resemble_intelligence': | ||
| return 'resemble_intelligence' | ||
| case 'resemble_watermark_detect': | ||
| return 'resemble_watermark_detect' | ||
| case 'resemble_watermark_apply': | ||
| return 'resemble_watermark_apply' | ||
| default: | ||
| return 'resemble_detect' | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| inputs: { | ||
| operation: { type: 'string', description: 'Operation to perform' }, | ||
| url: { type: 'string', description: 'Public HTTPS URL to the media' }, | ||
| runIntelligence: { type: 'boolean', description: 'Also run media intelligence' }, | ||
| audioSourceTracing: { type: 'boolean', description: 'Trace the source platform of fake audio' }, | ||
| visualize: { type: 'boolean', description: 'Generate heatmap artifacts' }, | ||
| useReverseSearch: { type: 'boolean', description: 'Image-only reverse image search' }, | ||
| useOodDetector: { type: 'boolean', description: 'Out-of-distribution detection' }, | ||
| zeroRetentionMode: { type: 'boolean', description: 'Auto-delete media after analysis' }, | ||
| modelTypes: { type: 'string', description: 'auto | image | talking_head' }, | ||
| structuredJson: { type: 'boolean', description: 'Return structured JSON fields' }, | ||
| mediaType: { type: 'string', description: 'auto | audio | video | image' }, | ||
| strength: { type: 'number', description: 'Watermark strength 0–1' }, | ||
| customMessage: { type: 'string', description: 'Watermark message' }, | ||
| apiKey: { type: 'string', description: 'Resemble API key' }, | ||
| }, | ||
|
|
||
| outputs: { | ||
| result: { type: 'json', description: 'Result from the selected Resemble operation' }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import type { ResembleDetectParams, ResembleResponse } from '@/tools/resemble/types' | ||
| import { authHeaders, baseOf, pollResource, rItem, sanitize } from '@/tools/resemble/utils' | ||
| import type { ToolConfig } from '@/tools/types' | ||
|
|
||
| export const detectTool: ToolConfig<ResembleDetectParams, ResembleResponse> = { | ||
| id: 'resemble_detect', | ||
| name: 'Resemble Deepfake Detection', | ||
| description: 'Detect whether media (audio, image, or video) is a deepfake / AI-generated.', | ||
| version: '1.0.0', | ||
| params: { | ||
| apiKey: { | ||
| type: 'string', | ||
| required: true, | ||
| visibility: 'user-only', | ||
| description: 'Resemble API key', | ||
| }, | ||
| url: { | ||
| type: 'string', | ||
| required: true, | ||
| visibility: 'user-or-llm', | ||
| description: 'Public HTTPS URL to the media', | ||
| }, | ||
| runIntelligence: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Also run media intelligence', | ||
| }, | ||
| audioSourceTracing: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Trace the source platform of fake audio', | ||
| }, | ||
| visualize: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Generate heatmap artifacts', | ||
| }, | ||
| useReverseSearch: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Image-only reverse image search', | ||
| }, | ||
| useOodDetector: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Out-of-distribution detection', | ||
| }, | ||
| zeroRetentionMode: { | ||
| type: 'boolean', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Auto-delete media after analysis', | ||
| }, | ||
| modelTypes: { | ||
| type: 'string', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'auto | image | talking_head', | ||
| }, | ||
| maxWaitSeconds: { | ||
| type: 'number', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'Max seconds to poll for the result', | ||
| }, | ||
| baseUrl: { | ||
| type: 'string', | ||
| required: false, | ||
| visibility: 'user-only', | ||
| description: 'API base URL override', | ||
| }, | ||
| }, | ||
| request: { | ||
| url: (p) => `${baseOf(p)}/detect`, | ||
| method: 'POST', | ||
| headers: (p) => authHeaders(p), | ||
| body: (p) => { | ||
| const b: Record<string, any> = { url: p.url } | ||
| if (p.runIntelligence) b.intelligence = true | ||
| if (p.audioSourceTracing) b.audio_source_tracing = true | ||
| if (p.visualize) b.visualize = true | ||
| if (p.useReverseSearch) b.use_reverse_search = true | ||
| if (p.useOodDetector) b.use_ood_detector = true | ||
| if (p.zeroRetentionMode) b.zero_retention_mode = true | ||
| if (p.modelTypes && p.modelTypes !== 'auto') b.model_types = p.modelTypes | ||
| return b | ||
| }, | ||
| }, | ||
| transformResponse: async (response: Response, params?: ResembleDetectParams) => { | ||
| const text = await response.text() | ||
| let data: any | ||
| try { | ||
| data = JSON.parse(text) | ||
| } catch { | ||
| data = { raw: text } | ||
| } | ||
| if (!response.ok) | ||
| throw new Error((data && data.message) || `Resemble API error: HTTP ${response.status}`) | ||
| const uuid = rItem(data).uuid | ||
| if (uuid && params) { | ||
| data = await pollResource( | ||
| baseOf(params), | ||
| `/detect/${uuid}`, | ||
| authHeaders(params), | ||
| params.maxWaitSeconds || 120 | ||
| ) | ||
| } | ||
| return { success: true, output: { result: sanitize(data) } } | ||
| }, | ||
| outputs: { | ||
| result: { | ||
| type: 'json', | ||
| description: 'Detection result (label, score, metrics, optional intelligence).', | ||
| }, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export { detectTool } from '@/tools/resemble/detect' | ||
| export { intelligenceTool } from '@/tools/resemble/intelligence' | ||
| export * from '@/tools/resemble/types' | ||
| export { watermarkApplyTool } from '@/tools/resemble/watermark_apply' | ||
| export { watermarkDetectTool } from '@/tools/resemble/watermark_detect' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
structuredJsonparameter has no corresponding UI controlintelligenceTooldeclares astructuredJsonboolean param that controls whether the API returns structured JSON fields. Because no subBlock exists for it in the block definition, the value is alwaysundefinedin the UI, which causes the body builder to evaluatep.structuredJson !== falseastrue— permanently fixing it to structured mode. Users who need raw/unstructured output from the Intelligence operation cannot opt out from the block UI.