Skip to content

Commit

Permalink
All regions have openai vectorize + fix async chat memory test (#37)
Browse files Browse the repository at this point in the history
* all regions have openai vectorize

* prevent double createCollection statements for two-session-ids history tests
  • Loading branch information
hemidactylus authored Jun 24, 2024
1 parent 076b0ab commit 8298f84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ def history1() -> Iterable[AstraDBChatMessageHistory]:


@pytest.fixture(scope="function")
def history2() -> Iterable[AstraDBChatMessageHistory]:
def history2(
history1: AstraDBChatMessageHistory,
) -> Iterable[AstraDBChatMessageHistory]:
history2 = AstraDBChatMessageHistory(
session_id="session-test-2",
collection_name="langchain_cmh_test",
collection_name=history1.collection_name,
token=os.environ["ASTRA_DB_APPLICATION_TOKEN"],
api_endpoint=os.environ["ASTRA_DB_API_ENDPOINT"],
namespace=os.environ.get("ASTRA_DB_KEYSPACE"),
# this, with the dependency from history1, ensures
# no two createCollection calls at once are issued:
setup_mode=SetupMode.OFF,
)
yield history2
history2.collection.astra_db.delete_collection("langchain_cmh_test")
# no deletion here, this is riding on history1


@pytest.fixture
Expand All @@ -61,17 +66,21 @@ async def async_history1() -> AsyncIterable[AstraDBChatMessageHistory]:


@pytest.fixture(scope="function")
async def async_history2() -> AsyncIterable[AstraDBChatMessageHistory]:
async def async_history2(
history1: AstraDBChatMessageHistory,
) -> AsyncIterable[AstraDBChatMessageHistory]:
history2 = AstraDBChatMessageHistory(
session_id="async-session-test-2",
collection_name="langchain_cmh_test",
collection_name=history1.collection_name,
token=os.environ["ASTRA_DB_APPLICATION_TOKEN"],
api_endpoint=os.environ["ASTRA_DB_API_ENDPOINT"],
namespace=os.environ.get("ASTRA_DB_KEYSPACE"),
setup_mode=SetupMode.ASYNC,
# this, with the dependency from history1, ensures
# no two createCollection calls at once are issued:
setup_mode=SetupMode.OFF,
)
yield history2
await history2.async_collection.astra_db.delete_collection("langchain_cmh_test")
# no deletion here, this is riding on history1


@pytest.mark.skipif(not _has_env_vars(), reason="Missing Astra DB env. vars")
Expand Down
11 changes: 1 addition & 10 deletions libs/astradb/tests/integration_tests/test_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@

MATCH_EPSILON = 0.0001

# For the time being, prod-regions described only
OPENAI_VECTORIZE_REGIONS_MAP = {
"prod": {"us-east-2", "westus3", "us-east1"}, # resp. aws, azure, gcp
}

openai_vectorize_options = CollectionVectorServiceOptions(
provider="openai",
Expand Down Expand Up @@ -79,14 +75,9 @@ def is_openai_vector_service_available() -> bool:
env = "prod"
else:
env = "other"
openai_vectorize_regions = OPENAI_VECTORIZE_REGIONS_MAP.get(env, set())
return all(
[
any(
openai_region in os.environ.get("ASTRA_DB_API_ENDPOINT", "")
for openai_region in openai_vectorize_regions
),
"astra.datastax.com" in os.environ.get("ASTRA_DB_API_ENDPOINT", ""),
env == "prod",
os.environ.get("SHARED_SECRET_NAME_OPENAI"),
]
)
Expand Down

0 comments on commit 8298f84

Please sign in to comment.