Skip to content

Commit

Permalink
ndb client
Browse files Browse the repository at this point in the history
  • Loading branch information
drf7 committed Jan 7, 2025
1 parent 1a46960 commit 04c5b76
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
10 changes: 9 additions & 1 deletion nuclia_e2e/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from nuclia.config import set_config_file
from nuclia.data import get_auth
from nuclia.data import get_config
from nuclia.lib.kb import AsyncNucliaDBClient
from nuclia.lib.kb import Environment
from nuclia.sdk.kbs import NucliaKBS
from nuclia_e2e.tests.data import TEST_ACCOUNT_SLUG
from tests.data import TEST_ACCOUNT_SLUG

import aiohttp
import asyncio
Expand Down Expand Up @@ -193,6 +195,12 @@ def regional_api_config(request, global_api_config):
config.set_default_account(global_api_config["permanent_account_slug"])
config.set_default_zone(zone_config["zone_slug"])
zone_config["test_kb_slug"] = "{test_kb_slug}-{name}".format(**zone_config)
zone_config["ndb"] = AsyncNucliaDBClient(
environment=Environment.CLOUD,
url=regional_api_config["base_url"],
user_token=regional_api_config["user_token"],
region=regional_api_config["name"],
)
return zone_config


Expand Down
13 changes: 11 additions & 2 deletions nuclia_e2e/tests/test_kb.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ async def run_test_ask(regional_api_config):
features=["keyword", "semantic", "relations"],
query="why cocoa prices high?",
model="chatgpt4o",
ndb=regional_api_config["ndb"],
)

assert "climate change" in ask_result.answer.decode().lower()

ask_more_result = await kb.search.ask(
autofilter=True,
rephrase=True,
Expand All @@ -263,6 +264,7 @@ async def run_test_ask(regional_api_config):
],
query="when?",
model="chatgpt4o",
ndb=regional_api_config["ndb"],
)
assert "earlier" in ask_more_result.answer.decode().lower()

Expand Down Expand Up @@ -341,7 +343,14 @@ async def condition() -> tuple[bool, Any]:
async def run_test_kb_deletion(regional_api_config):
kbs = NucliaKBS()
print("deleting " + regional_api_config["test_kb_slug"])
await asyncio.to_thread(partial(kbs.delete, slug=regional_api_config["test_kb_slug"]))
await asyncio.to_thread(
partial(
kbs.delete,
slug=regional_api_config["test_kb_slug"],
zone=regional_api_config["name"],
account=regional_api_config["permanent_account_slug"],
)
)

kbid = await get_kbid_from_slug(regional_api_config["test_kb_slug"])
assert kbid is None
Expand Down
4 changes: 2 additions & 2 deletions nuclia_e2e/tests/test_onboarding.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from nuclia_e2e.tests.data import TEST_ACCOUNT_SLUG
from nuclia_e2e.tests.data import TEST_ONBOARD_INQUIRY
from tests.data import TEST_ACCOUNT_SLUG
from tests.data import TEST_ONBOARD_INQUIRY

import pytest

Expand Down

0 comments on commit 04c5b76

Please sign in to comment.