Skip to content

feat(embedding-model-v2): add providerOptions #5698

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

Merged
merged 5 commits into from
Apr 14, 2025

Conversation

samdenty
Copy link
Contributor

@samdenty samdenty commented Apr 11, 2025

Background

Summary

This adds providerOptions to embedding model v2 for future PRs

Tasks

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • If required, a patch changeset for relevant packages has been added
  • You've run pnpm prettier-fix to fix any formatting issues

Future Work

@lgrammel
Copy link
Collaborator

This needs to be introduced end-to-end, i.e. embed and embedMany need support & tests.

Copy link
Collaborator

@lgrammel lgrammel left a comment

Choose a reason for hiding this comment

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

Please remove Zod and revert shared types.

@samdenty samdenty force-pushed the feat/embedding-v2-providerOptions branch from 3ab9610 to 5a6339f Compare April 13, 2025 15:06
@samdenty samdenty requested a review from lgrammel April 13, 2025 15:07
…derOptions

* origin/v5:
  chore: update .gitignore (#5755)
  chore: refactor source parts (spec) (#5753)
  chore: refactor file parts (spec) (#5750)
  chore: refactor tool call and tool call delta parts (spec) (#5746)
  fix(providers/xai): edit supported models for structured output (#5715) (#5741)
@samdenty samdenty merged commit 393138b into v5 Apr 14, 2025
7 checks passed
@samdenty samdenty deleted the feat/embedding-v2-providerOptions branch April 14, 2025 15:19
samdenty added a commit that referenced this pull request Apr 15, 2025
* origin/v5: (36 commits)
  fix (provider): remove deprecated `Experimental_LanguageModelV2Middleware` (#5775)
  fix (ai): remove deprecated `options.throwErrorForEmptyVectors` from `cosineSimilarity()` (#5772)
  fix (ai/core): filter out empty content/text assistant messages (#5767) (#5783)
  fix (ai): remove deprecated `CoreTool*` types (#5768)
  chore: refactor text parts (spec) (#5759)
  feat(embedding-model-v2): add response body field (#5700)
  feat(embedding-model-v2): add providerOptions (#5698)
  chore: refactor reasoning parts (spec) (#5756)
  chore: update .gitignore (#5755)
  chore: refactor source parts (spec) (#5753)
  chore: refactor file parts (spec) (#5750)
  chore: refactor tool call and tool call delta parts (spec) (#5746)
  fix(providers/xai): edit supported models for structured output (#5715) (#5741)
  chore (ai): remove provider re-exports (#5734)
  chore (provider): extract shared provider options and metadata (spec) (#5733)
  fix(ai/core): properly handle custom separator in provider registry (#5713) (#5732)
  chore (providers/xai): update grok-3 model aliases (#5646)
  chore(embedding-model-v2): rename rawResponse to response (#5699)
  chore(providers/mistral): convert to providerOptions (#5675)
  chore: refactor file towards source pattern (spec) (#5709)
  ...
samdenty added a commit that referenced this pull request Apr 15, 2025
…der-options

* origin/v5: (36 commits)
  fix (provider): remove deprecated `Experimental_LanguageModelV2Middleware` (#5775)
  fix (ai): remove deprecated `options.throwErrorForEmptyVectors` from `cosineSimilarity()` (#5772)
  fix (ai/core): filter out empty content/text assistant messages (#5767) (#5783)
  fix (ai): remove deprecated `CoreTool*` types (#5768)
  chore: refactor text parts (spec) (#5759)
  feat(embedding-model-v2): add response body field (#5700)
  feat(embedding-model-v2): add providerOptions (#5698)
  chore: refactor reasoning parts (spec) (#5756)
  chore: update .gitignore (#5755)
  chore: refactor source parts (spec) (#5753)
  chore: refactor file parts (spec) (#5750)
  chore: refactor tool call and tool call delta parts (spec) (#5746)
  fix(providers/xai): edit supported models for structured output (#5715) (#5741)
  chore (ai): remove provider re-exports (#5734)
  chore (provider): extract shared provider options and metadata (spec) (#5733)
  fix(ai/core): properly handle custom separator in provider registry (#5713) (#5732)
  chore (providers/xai): update grok-3 model aliases (#5646)
  chore(embedding-model-v2): rename rawResponse to response (#5699)
  chore(providers/mistral): convert to providerOptions (#5675)
  chore: refactor file towards source pattern (spec) (#5709)
  ...
gr2m added a commit that referenced this pull request Apr 30, 2025
…5977)

## Background

Compare #5698

## Summary

Additional provider-specific options to the image model provider
interface. They are passed through to the provider from the AI SDK and
enable provider-specific functionality that can be fully encapsulated in
the provider.

Unlike other models, ImageModel request return an array of images, and
provider can return image-specific metadata for each. So far, this pull
request passing through the revised prompt used for each image. In order
to make that possible, I introduced a new type
`ImageModelV2ProviderMetadata` which is the same as
`SharedV2ProviderMetadata` plus it guarantees the presence of the
`.images` key

```js
export type ImageModelV2ProviderMetadata = Record<
  string,
  {
    images: JSONArray;
  } & JSONValue
>;
```

That also makes it possible to deeply merge providerMetadata from
multiple responses effectively.

## Verification

I updated the `examples/ai-core/src/generate-image/openai.ts` example to
verify that the code is working.
iteratetograceness pushed a commit to iteratetograceness/ai that referenced this pull request May 9, 2025
…ercel#5977)

## Background

Compare vercel#5698

## Summary

Additional provider-specific options to the image model provider
interface. They are passed through to the provider from the AI SDK and
enable provider-specific functionality that can be fully encapsulated in
the provider.

Unlike other models, ImageModel request return an array of images, and
provider can return image-specific metadata for each. So far, this pull
request passing through the revised prompt used for each image. In order
to make that possible, I introduced a new type
`ImageModelV2ProviderMetadata` which is the same as
`SharedV2ProviderMetadata` plus it guarantees the presence of the
`.images` key

```js
export type ImageModelV2ProviderMetadata = Record<
  string,
  {
    images: JSONArray;
  } & JSONValue
>;
```

That also makes it possible to deeply merge providerMetadata from
multiple responses effectively.

## Verification

I updated the `examples/ai-core/src/generate-image/openai.ts` example to
verify that the code is working.
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.

2 participants