This commit is contained in:
IAN MILLER 2025-10-03 04:57:49 -07:00 committed by GitHub
commit 7774d9e9f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
80 changed files with 32197 additions and 186 deletions

View file

@ -374,8 +374,20 @@ def test_openai_vector_store_search_with_ranking_options(
chunks=sample_chunks,
)
# First search without threshold to determine reasonable threshold
initial_search = compat_client.vector_stores.search(
vector_store_id=vector_store.id,
query="machine learning and artificial intelligence",
max_num_results=3,
)
# Use a threshold that's lower than the lowest score to ensure we get results
if initial_search.data:
threshold = min(result.score for result in initial_search.data) * 0.9
else:
threshold = 0.01
# Search with ranking options
threshold = 0.1
search_response = compat_client.vector_stores.search(
vector_store_id=vector_store.id,
query="machine learning and artificial intelligence",
@ -490,7 +502,12 @@ def test_openai_vector_store_attach_file(compat_client_with_empty_stores, client
test_content = b"The secret string is foobazbar."
with BytesIO(test_content) as file_buffer:
file_buffer.name = "openai_test.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
# Attach the file to the vector store
file_attach_response = compat_client.vector_stores.files.create(
@ -536,7 +553,12 @@ def test_openai_vector_store_attach_files_on_creation(compat_client_with_empty_s
for i in range(3):
with BytesIO(f"This is a test file {i}".encode()) as file_buffer:
file_buffer.name = f"openai_test_{i}.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
valid_file_ids.append(file.id)
# include an invalid file ID so we can test failed status
@ -592,7 +614,12 @@ def test_openai_vector_store_list_files(compat_client_with_empty_stores, client_
for i in range(3):
with BytesIO(f"This is a test file {i}".encode()) as file_buffer:
file_buffer.name = f"openai_test_{i}.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
response = compat_client.vector_stores.files.create(
vector_store_id=vector_store.id,
@ -668,7 +695,12 @@ def test_openai_vector_store_retrieve_file_contents(compat_client_with_empty_sto
attributes = {"foo": "bar"}
with BytesIO(test_content) as file_buffer:
file_buffer.name = file_name
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
# Attach the file to the vector store
file_attach_response = compat_client.vector_stores.files.create(
@ -711,7 +743,12 @@ def test_openai_vector_store_delete_file(compat_client_with_empty_stores, client
for i in range(3):
with BytesIO(f"This is a test file {i}".encode()) as file_buffer:
file_buffer.name = f"openai_test_{i}.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
compat_client.vector_stores.files.create(
vector_store_id=vector_store.id,
@ -762,7 +799,12 @@ def test_openai_vector_store_delete_file_removes_from_vector_store(compat_client
test_content = b"The secret string is foobazbar."
with BytesIO(test_content) as file_buffer:
file_buffer.name = "openai_test.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
# Attach the file to the vector store
file_attach_response = compat_client.vector_stores.files.create(
@ -800,7 +842,12 @@ def test_openai_vector_store_update_file(compat_client_with_empty_stores, client
test_content = b"This is a test file"
with BytesIO(test_content) as file_buffer:
file_buffer.name = "openai_test.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
# Attach the file to the vector store
file_attach_response = compat_client.vector_stores.files.create(
@ -843,7 +890,12 @@ def test_create_vector_store_files_duplicate_vector_store_name(compat_client_wit
for i in range(3):
with BytesIO(f"This is a test file {i}".encode()) as file_buffer:
file_buffer.name = f"openai_test_{i}.txt"
file = compat_client.files.create(file=file_buffer, purpose="assistants")
file = compat_client.files.create(
file=file_buffer,
purpose="assistants",
expires_after_anchor="created_at",
expires_after_seconds=86400, # 24 hours
)
file_ids.append(file.id)
vector_store = compat_client.vector_stores.create(