Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/app/api/docs/collections/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ pipeline:

* Create a vector store from the document IDs you received after uploading your
documents through the Documents module.
* The `batch_size` parameter controls how many documents are sent to OpenAI in a
single transaction when creating the vector store. This helps optimize the upload
process for large document sets. If not specified, the default value is **10**.
* [Deprecated] Attach the Vector Store to an OpenAI
[Assistant](https://platform.openai.com/docs/api-reference/assistants). Use
parameters in the request body relevant to an Assistant to flesh out
Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CollectionOptions(SQLModel):
description="List of document IDs",
)
batch_size: int = Field(
default=1,
default=10,
description=(
"Number of documents to send to OpenAI in a single "
"transaction. See the `file_ids` parameter in the "
Expand Down
4 changes: 3 additions & 1 deletion backend/app/services/collections/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def create(
Create OpenAI vector store with documents and optionally an assistant.
"""
try:
# Use user-provided batch_size, default to 10 if not set
batch_size = collection_request.batch_size or 10
docs_batches = batch_documents(
document_crud,
collection_request.documents,
collection_request.batch_size,
batch_size,
)

vector_store_crud = OpenAIVectorStoreCrud(self.client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_collection_creation_with_assistant_calls_start_job_and_returns_job(
instructions="string",
temperature=0.000001,
documents=[UUID("f3e86a17-1e6f-41ec-b020-5b08eebef928")],
batch_size=1,
batch_size=10,
callback_url=None,
)

Expand Down Expand Up @@ -71,7 +71,7 @@ def test_collection_creation_vector_only_adds_metadata_and_sets_with_assistant_f
creation_data = CreationRequest(
temperature=0.000001,
documents=[str(uuid4())],
batch_size=1,
batch_size=10,
callback_url=None,
)

Expand Down Expand Up @@ -109,7 +109,7 @@ def test_collection_creation_vector_only_request_validation_error(
"model": "gpt-4o",
"temperature": 0.000001,
"documents": [str(uuid4())],
"batch_size": 1,
"batch_size": 10,
"callback_url": None,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_create_openai_vector_store_only() -> None:

collection_request = SimpleNamespace(
documents=["doc1", "doc2"],
batch_size=1,
batch_size=10,
model=None,
instructions=None,
temperature=None,
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_create_openai_with_assistant() -> None:

collection_request = SimpleNamespace(
documents=["doc1"],
batch_size=1,
batch_size=10,
model="gpt-4o",
instructions="You are helpful",
temperature=0.7,
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_create_propagates_exception() -> None:

collection_request = SimpleNamespace(
documents=["doc1"],
batch_size=1,
batch_size=10,
model=None,
instructions=None,
temperature=None,
Expand Down
12 changes: 6 additions & 6 deletions backend/app/tests/services/collections/test_create_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non
project = get_project(db)
request = CreationRequest(
documents=[UUID("f3e86a17-1e6f-41ec-b020-5b08eebef928")],
batch_size=1,
batch_size=10,
callback_url=None,
provider="openai",
)
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_execute_job_success_flow_updates_job_and_creates_collection(
aws.client.put_object(Bucket=settings.AWS_S3_BUCKET, Key=str(s3_key), Body=b"test")

sample_request = CreationRequest(
documents=[document.id], batch_size=1, callback_url=None, provider="openai"
documents=[document.id], batch_size=10, callback_url=None, provider="openai"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not sure how this works, but increasing size and still passing one document id does not make sense. it should be list of documents somewhere but not sure about rest of the code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes, can write a test where num docs >10, and the test can then check whether batching happens as expected

)

mock_get_llm_provider.return_value = get_mock_provider(
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_execute_job_assistant_create_failure_marks_failed_and_deletes_collectio
)

req = CreationRequest(
documents=[], batch_size=1, callback_url=None, provider="openai"
documents=[], batch_size=10, callback_url=None, provider="openai"
)

mock_provider = get_mock_provider(
Expand Down Expand Up @@ -269,7 +269,7 @@ def test_execute_job_success_flow_callback_job_and_creates_collection(

sample_request = CreationRequest(
documents=[document.id],
batch_size=1,
batch_size=10,
callback_url=callback_url,
provider="openai",
)
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_execute_job_success_creates_collection_with_callback(

sample_request = CreationRequest(
documents=[document.id],
batch_size=1,
batch_size=10,
callback_url=callback_url,
provider="openai",
)
Expand Down Expand Up @@ -434,7 +434,7 @@ def test_execute_job_failure_flow_callback_job_and_marks_failed(

sample_request = CreationRequest(
documents=[uuid.uuid4()],
batch_size=1,
batch_size=10,
callback_url=callback_url,
provider="openai",
)
Expand Down
Loading