Skip to content

Add embed to Index configure calls #515

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 16 commits into from
Jun 18, 2025

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Jun 16, 2025

Problem

embed was never exposed as an argument for calling configure on IndexResource.

Solution

  • Add a new simple ConfigureIndexEmbed(TypedDict) class for representing the argument dictionary shape. I went with this because it aligned with the existing CreateIndexForModelEmbedTypedDict, but I'm not sure if this is best practice in the repo at this point. Maybe a class would be better.
  • Update factory, sync, and async resources to pass through embed on configure calls.
  • Update legacy Pinecone.configure_index method to support embed.
  • Add integration tests to serverless resources to validate converting an existing serverless index to an integrated index using configure or configure_index.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

New integration tests added. You can pull this branch down and use poetry to run a repl and quickly evaluate things yourself:

poetry run repl

>>> from pinecone import Pinecone
>>> pc = Pinecone(api_key="YOUR_API_KEY")

>>> pc.create_index(name="test-int-inf-convert", dimension=1024, metric="cosine", spec={"serverless": {"cloud": "aws", "region": "us-east-1"}})
{
    "name": "test-int-inf-convert",
    "metric": "cosine",
    "host": "test-int-inf-convert-bt8x3su.svc.preprod-aws-0.pinecone.io",
    "spec": {
        "serverless": {
            "cloud": "aws",
            "region": "us-east-1"
        }
    },
    "status": {
        "ready": true,
        "state": "Ready"
    },
    "vector_type": "dense",
    "dimension": 1024,
    "deletion_protection": "disabled",
    "tags": null
}

>>> pc.db.index.configure(name="test-int-inf-convert", embed={"model": "multilingual-e5-large", "field_map":{"text": "chunk_text"}})
>>> pc.db.index.describe(name="test-int-inf-convert")
{
    "name": "test-int-inf-convert",
    "metric": "cosine",
    "host": "test-int-inf-convert-bt8x3su.svc.preprod-aws-0.pinecone.io",
    "spec": {
        "serverless": {
            "cloud": "aws",
            "region": "us-east-1"
        }
    },
    "status": {
        "ready": true,
        "state": "Ready"
    },
    "vector_type": "dense",
    "dimension": 1024,
    "deletion_protection": "disabled",
    "tags": null,
    "embed": {
        "model": "multilingual-e5-large",
        "field_map": {
            "text": "chunk_text"
        },
        "dimension": 1024,
        "metric": "cosine",
        "write_parameters": {
            "input_type": "passage",
            "truncate": "END"
        },
        "read_parameters": {
            "input_type": "query",
            "truncate": "END"
        },
        "vector_type": "dense"
    }
}

### repeat with async resources / pc.configure_index()

@austin-denoble austin-denoble marked this pull request as ready for review June 17, 2025 19:00
@@ -98,6 +98,11 @@
"RestoreJobList": ("pinecone.db_control.models", "RestoreJobList"),
"BackupModel": ("pinecone.db_control.models", "BackupModel"),
"BackupList": ("pinecone.db_control.models", "BackupList"),
"ConfigureIndexEmbed": ("pinecone.db_control.types", "ConfigureIndexEmbed"),
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reason for adding ConfigureIndexEmbed and CreateIndexForModelEmbedTypedDict here?

Copy link
Contributor Author

@austin-denoble austin-denoble Jun 18, 2025

Choose a reason for hiding this comment

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

Adding the classes to _db_control_lazy_imports, which we seem to do for all of our custom models and types. It seemed like CreateIndexForModelEmbedTypedDict was also not included here, so I added it.

This is to allow lazy loaded imports to be exported from the top level of the package here:

*list(_LAZY_IMPORTS.keys()),

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I was wondering why we added types here but here's the reason why:
#507 (comment)

Copy link
Contributor

@rohanshah18 rohanshah18 left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work. Also it makes sense to follow CreateIndexForModelEmbed approach.

@austin-denoble austin-denoble merged commit 28c142a into main Jun 18, 2025
68 checks passed
@austin-denoble austin-denoble deleted the adenoble/add-embed-to-index-configure branch June 18, 2025 16:44
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