openai / openai/openai-python

The return value of the vector_stores.file_batches.poll method contains the ID of the VectorStore.

Open
#2,724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
31.6k
Forks
5.7k
Avg merge
1d 6h
Merged PRs (30d)
96

Description

Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

The expected result is that the file_batches object ID should be stored and returned.

To Reproduce

Run the sample code.
call poll method.

Code snippets
import openai

file_obj = None
vector_store_obj = None

try:
    client = openai.OpenAI(
        api_key=os.environ['OPENAI_API_KEY']
    )
    file_obj = client.files.create(file=('test_data.json', b'{"aa": "AA"}\n'), purpose='user_data')
    vector_store_obj = client.vector_stores.create(name='test_vector_store')

    batch_obj = client.vector_stores.file_batches.create(
        vector_store_id=vector_store_obj.id,
        file_ids=[file_obj.id]
    )
    print(f'type:[{type(batch_obj)}]')
    print(batch_obj.model_dump_json(indent=2))

    response = client.vector_stores.file_batches.poll(batch_id=batch_obj.id, vector_store_id=vector_store_obj.id)
    print(f'type:[{type(response)}]')
    print(response.model_dump_json(indent=2))

    print("# The return value contains the vector_store id.")
    print("# Shouldn't the return value of the file_batches.poll method be the batch_obj ID?")
    print(f'# OpenAI version:[{openai.__version__}]')

finally:
    if file_obj:
        client.files.delete(file_id=file_obj.id)
    if vector_store_obj:
        client.vector_stores.delete(vector_store_id=vector_store_obj.id)

# Below are the execution results.
'''
type:[<class 'openai.types.vector_stores.vector_store_file_batch.VectorStoreFileBatch'>]
{
  "id": "vsfb_ibj_6905db4e33dc81f4a789ad8df2b5c748",
  "created_at": 1761991502,
  "file_counts": {
    "cancelled": 0,
    "completed": 0,
    "failed": 0,
    "in_progress": 1,
    "total": 1
  },
  "object": "vector_store.file_batch",
  "status": "in_progress",
  "vector_store_id": "vs_6905db4d53708191a75c5ef9979258fd"
}
type:[<class 'openai.types.vector_stores.vector_store_file_batch.VectorStoreFileBatch'>]
{
  "id": "vs_6905db4d53708191a75c5ef9979258fd",
  "created_at": 1761991501,
  "file_counts": {
    "cancelled": 0,
    "completed": 1,
    "failed": 0,
    "in_progress": 0,
    "total": 1
  },
  "object": "vector_store",
  "status": "completed",
  "vector_store_id": null,
  "name": "test_vector_store",
  "description": null,
  "usage_bytes": 0,
  "expires_after": null,
  "expires_at": null,
  "last_active_at": 1761991501,
  "metadata": {}
}
# The return value contains the vector_store id.
# Shouldn't the return value of the file_batches.poll method be the batch_obj ID?
# OpenAI version:[1.109.1]
'''
OS

Ubuntu24.04

Python version

Python3.12.3

Library version

openai v1.109.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the vector_stores.file_batches.poll method and reproduce the behavior with the sample code in this issue. Compare the returned VectorStoreFileBatch object's id and object fields with batch_obj; done means the poll result consistently represents the file batch and returns its expected ID, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.