Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pinecone-io/pinecone-java-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.1
Choose a base ref
...
head repository: pinecone-io/pinecone-java-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.0
Choose a head ref
  • 2 commits
  • 224 files changed
  • 1 contributor

Commits on Apr 9, 2025

  1. Add integrated inference (#181)

    ## Problem
    
    Add integrated inference to Java SDK.
    
    ## Solution
    
    The code was already generated since integrated inference was a part of
    2025-01 api spec. So as a part of this PR, I have added the following
    features:
    1. Create index for model i.e. create an index with an associated
    embedding model
    2. Configure an existing index to associate it with an embedding model
    3. Upsert records
    4. Search records by id
    5. Search records by vector
    6. Search records by text
    
    Example:
    ```java
    import io.pinecone.clients.Index;
    import io.pinecone.clients.Pinecone;
    import io.pinecone.helpers.RandomStringBuilder;
    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.Test;
    import org.openapitools.db_control.client.model.CreateIndexForModelRequest;
    import org.openapitools.db_control.client.model.CreateIndexForModelRequestEmbed;
    import org.openapitools.db_control.client.model.DeletionProtection;
    import org.openapitools.db_data.client.ApiException;
    import org.openapitools.db_data.client.model.SearchRecordsRequestQuery;
    import org.openapitools.db_data.client.model.SearchRecordsResponse;
    import org.openapitools.db_data.client.model.UpsertRecord;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    ...
    
        Pinecone pinecone = new Pinecone.Builder(System.getenv("PINECONE_API_KEY")).build();
        String indexName = RandomStringBuilder.build("inf", 8);
    
        // Create index associated with a model
        HashMap<String, String> fieldMap = new HashMap<>();
        fieldMap.put("text", "chunk_text");
        CreateIndexForModelRequestEmbed embed = new CreateIndexForModelRequestEmbed()
                .model("multilingual-e5-large")
                .fieldMap(fieldMap);
        pinecone.createIndexForModel(indexName, CreateIndexForModelRequest.CloudEnum.AWS, "us-west-2", embed, DeletionProtection.DISABLED, new HashMap<>());
    
        // Wait for index to be created
        Thread.sleep(10000);
    
        Index index = pinecone.getIndexConnection(indexName);
    
        // Upsert records
        HashMap<String, String> record1 = new HashMap<>();
        record1.put("_id", "rec1");
        record1.put("category", "digestive system");
        record1.put("chunk_text", "Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.");
    
        HashMap<String, String> record2 = new HashMap<>();
        record2.put("_id", "rec2");
        record2.put("category", "cultivation");
        record2.put("chunk_text", "Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.");
    
        HashMap<String, String> record3 = new HashMap<>();
        record3.put("_id", "rec3");
        record3.put("category", "immune system");
        record3.put("chunk_text", "Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.");
    
        HashMap<String, String> record4 = new HashMap<>();
        record4.put("_id", "rec4");
        record4.put("category", "endocrine system");
        record4.put("chunk_text", "The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.");
    
        upsertRecords.add(record1);
        upsertRecords.add(record2);
        upsertRecords.add(record3);
        upsertRecords.add(record4);
    
        index.upsertRecords("example-namespace", upsertRecords);
    
        // Wait for vectors to be upserted
        Thread.sleep(5000);
    
        String namespace = "example-namespace";
        List<String> fields = new ArrayList<>();
        fields.add("category");
        fields.add("chunk_text");
    
        SearchRecordsRequestRerank rerank = new SearchRecordsRequestRerank()
            .model("bge-reranker-v2-m3")
            .topN(2)
            .rankFields(Arrays.asList("chunk_text"));
        
        // Search records
        SearchRecordsResponse recordsResponse = index.searchRecordsByText("Disease prevention", namespace, fields, 4, null, rerank);
        System.out.println(recordsResponse);
    ```
    
    ## Type of Change
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [X] 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
    
    Added integration test that creates an index associated with a model,
    upserts and queries records.
    rohanshah18 authored Apr 9, 2025
    Configuration menu
    Copy the full SHA
    ee5d882 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2025

  1. Generate code for 2025-04, automate ndjson handling, add backups, res…

    …tore, and namespaces. (#183)
    
    ## Problem
    
    1. Generate code for 2025-04 and automate ndjson handling.
    2. Add support for backups and restore.
    3. Add support for namespaces
    
    ## Solution
    
    1. Generated code using the 2025-04 open api spec and added sed command
    to automate the process of handling ndjson which is currently not
    handled by the open api genearted code in ApiClient.java of data.yaml
    module.
    2. Added support for backups and restore
    3. Added support for namespaces
    
    ## Type of Change
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [X] 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
    
    Integration tests were added for new features.
    rohanshah18 authored May 9, 2025
    Configuration menu
    Copy the full SHA
    cb00bc3 View commit details
    Browse the repository at this point in the history
Loading