Conversation
Add _translate_embed_to_semantic_text() method to PineconeDBControlRequestFactory
that converts create_index_for_model parameters (cloud, region, embed) to the
new API format using deployment and schema with semantic_text field type.
Translation logic:
- cloud/region -> ServerlessDeployment
- IndexEmbed.model -> semantic_text field model
- IndexEmbed.metric -> semantic_text field metric (if provided)
- IndexEmbed.field_map values -> schema field names
- Default read_parameters: {"input_type": "query"}
- Default write_parameters: {"input_type": "passage"}
Refs: SDK-105
|
|
||
| schema_dict["fields"][target_field] = field_config | ||
|
|
||
| return deployment_dict, schema_dict |
There was a problem hiding this comment.
New function defined but never called in production code
Low Severity
The _translate_embed_to_semantic_text method is defined and has unit tests, but is never called from any production code path. The only references outside the definition itself are in the docstring example and test files. This is scaffolding code that hasn't been integrated into the actual request flow (e.g., create_index_for_model_request doesn't call it).
When multiple fields exist in field_map and custom read/write parameters are provided, each field now gets an independent copy of the dictionary instead of sharing the same reference.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| # Include metric if provided | ||
| if metric is not None: | ||
| field_config["metric"] = convert_enum_to_string(metric) |
There was a problem hiding this comment.
Redundant enum conversion call on already-converted metric
Low Severity
The convert_enum_to_string(metric) call at line 581 is redundant because metric is already guaranteed to be a string (or None) at this point. For IndexEmbed objects, the metric attribute is converted to a string in IndexEmbed.__init__ (line 62 of index_embed.py). For dict-based embeds, the conversion already happens at line 559. Calling convert_enum_to_string on an already-converted string value just returns it unchanged, adding unnecessary overhead.
Summary
Add
_translate_embed_to_semantic_text()method toPineconeDBControlRequestFactorythat convertscreate_index_for_modelparameters to the new API format withdeployment+schemacontaining asemantic_textfield type.Translation example:
Key features:
cloud/regiontoServerlessDeploymentfield_mapvaluesread_parameters({"input_type": "query"}) andwrite_parameters({"input_type": "passage"}) if not providedIndexEmbedobjects and dict-based embed configurationsRelated Issues
Test Plan
Note: Full unit test execution is blocked on SDK-116 (re-enable CI for fts branch) due to OpenAPI model compatibility issues.
Note
Low Risk
Low risk: this introduces a new translation helper and tests without changing existing request-building behavior.
Overview
Adds
PineconeDBControlRequestFactory._translate_embed_to_semantic_text()to convertcloud/region+IndexEmbed(or dict) into a serverlessdeploymentdict and aschemacontaining one or moresemantic_textfields derived fromfield_map, including defaultread_parameters/write_parametersand enum-to-string handling.Adds unit tests covering basic translation, custom parameters, optional metric handling, multiple mapped fields (with independent parameter dict copies), enum inputs, and validation errors for missing/empty embed fields.
Written by Cursor Bugbot for commit 266687b. This will update automatically on new commits. Configure here.