Skip to content

feat: agent.action.transform can now transform images to text descriptions #1096

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
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

snorrees
Copy link
Contributor

@snorrees snorrees commented Jun 1, 2025

image

Read README/TSDoc changes for what this does.

The above fields was generated for the image using this request:

//Populate multiple descriptions for the same image with different insturctions
client.agent.action.transform({
  schemaId,
  documentId,
  instruction: 'describe the image in great detail',
  target: [
    {path: ['image', 'alt'], operation: {type: 'image-description'}},
    {
      path: ['image', 'wrapper', 'alt'],
      operation: {type: 'image-description'},
      instruction: 'super short description',
    },
    {
      path: ['image', 'wrapper', 'description'],
      operation: {type: 'image-description'},
      instruction:
        'Describe the image in great detail. Use headings, paragraohs and formatting to structure the description.',
    },
  ],
})

npm i @sanity/client@agent-actions
7.4.0-agent-actions.2

@snorrees snorrees requested a review from markmichon June 1, 2025 20:41
Copy link

vercel bot commented Jun 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
tsdocs-client ⬜️ Ignored (Inspect) Jun 2, 2025 9:02pm

Copy link
Contributor

github-actions bot commented Jun 1, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 88.52% 3488 / 3940
🔵 Statements 88.52% 3488 / 3940
🔵 Functions 87.57% 289 / 330
🔵 Branches 89.11% 1032 / 1158
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/types.ts 0% 0% 0% 0%
src/agent/actions/transform.ts 100% 100% 100% 100%
Generated in workflow #3416 for commit 3967c96 by the Vitest Coverage Report Action

robinpyon
robinpyon previously approved these changes Jun 2, 2025
Copy link

@robinpyon robinpyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (Assuming sourcePath on image-description is coming later)

@snorrees
Copy link
Contributor Author

snorrees commented Jun 2, 2025

LGTM! (Assuming sourcePath on image-description is coming later)

I think I might just change it, and not keep the string version, just so sourcePath is more discoverable when you look for image-description

@snorrees snorrees requested a review from robinpyon June 2, 2025 21:02
`sourcePath` must be an image or image asset field.

For example:
- `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
- `target: {path: ['description'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants