Skip to content

Commit

Permalink
Convert collection id to UUID, PG Vector image needs a set variable t…
Browse files Browse the repository at this point in the history
…o change port (#1635)

* Convert collection id to UUID, PG Vector image needs a set variable

* Another

* Clean up, passing tests

* Comment out main

* Increase test timeout
  • Loading branch information
NolanTrem authored Nov 26, 2024
1 parent 2dbecbe commit 749a9c8
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 27 deletions.
10 changes: 5 additions & 5 deletions js/sdk/__tests__/r2rClientIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ describe("r2rClient Integration Tests", () => {
metadatas: [{ title: "raskolnikov.txt" }, { title: "karamozov.txt" }],
}),
).resolves.not.toThrow();
});
}, 30000);

test("Ingest files in folder", async () => {
const files = ["examples/data/folder"];

await expect(client.ingestFiles(files)).resolves.not.toThrow();
});
}, 30000);

test("Update files", async () => {
const updated_file = [
Expand All @@ -148,13 +148,13 @@ describe("r2rClient Integration Tests", () => {
metadatas: [{ title: "updated_karamozov.txt" }],
}),
).resolves.not.toThrow();
});
}, 30000);

test("Ingest chunks with no id or metadata", async () => {
await expect(
client.ingestChunks([{ text: "test chunks" }]),
).resolves.not.toThrow();
});
}, 30000);

test("Ingest chunks", async () => {
await expect(
Expand All @@ -164,7 +164,7 @@ describe("r2rClient Integration Tests", () => {
{ source: "example" },
),
).resolves.not.toThrow();
});
}, 30000);

test("Search documents", async () => {
await expect(client.search("test")).resolves.not.toThrow();
Expand Down
6 changes: 3 additions & 3 deletions js/sdk/__tests__/r2rClientIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ describe("r2rClient Integration Tests", () => {
metadatas: [{ title: "raskolnikov.txt" }],
}),
).resolves.not.toThrow();
});
}, 30000);

test("Ingest files in folder", async () => {
const files = ["examples/data/folder"];

await expect(client.ingestFiles(files)).resolves.not.toThrow();
});
}, 30000);

test("Update files", async () => {
const updated_file = [
Expand All @@ -165,7 +165,7 @@ describe("r2rClient Integration Tests", () => {
document_ids: ["0b80081e-a37a-579f-a06d-7d2032435d65"],
}),
).resolves.not.toThrow();
});
}, 30000);

test("Search documents", async () => {
await expect(client.search("test")).resolves.not.toThrow();
Expand Down
3 changes: 2 additions & 1 deletion py/compose.full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ services:
- POSTGRES_HOST=${R2R_POSTGRES_HOST:-${POSTGRES_HOST:-postgres}} # Eventually get rid of POSTGRES_HOST, but for now keep it for backwards compatibility
- POSTGRES_PORT=${R2R_POSTGRES_PORT:-${POSTGRES_PORT:-5432}} # Eventually get rid of POSTGRES_PORT, but for now keep it for backwards compatibility
- POSTGRES_MAX_CONNECTIONS=${R2R_POSTGRES_MAX_CONNECTIONS:-${POSTGRES_MAX_CONNECTIONS:-1024}} # Eventually get rid of POSTGRES_MAX_CONNECTIONS, but for now keep it for backwards compatibility
- PGPORT=${R2R_POSTGRES_PORT:-5432}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- r2r-network
ports:
- "${R2R_POSTGRES_PORT:-5432}:5432"
- "${R2R_POSTGRES_PORT:-5432}:${R2R_POSTGRES_PORT:-5432}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${R2R_POSTGRES_USER:-postgres}"]
interval: 10s
Expand Down
3 changes: 2 additions & 1 deletion py/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ services:
- POSTGRES_HOST=${R2R_POSTGRES_HOST:-${POSTGRES_HOST:-postgres}} # Eventually get rid of POSTGRES_HOST, but for now keep it for backwards compatibility
- POSTGRES_PORT=${R2R_POSTGRES_PORT:-${POSTGRES_PORT:-5432}} # Eventually get rid of POSTGRES_PORT, but for now keep it for backwards compatibility
- POSTGRES_MAX_CONNECTIONS=${R2R_POSTGRES_MAX_CONNECTIONS:-${POSTGRES_MAX_CONNECTIONS:-1024}} # Eventually get rid of POSTGRES_MAX_CONNECTIONS, but for now keep it for backwards compatibility
- PGPORT=${R2R_POSTGRES_PORT:-5432}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- r2r-network
ports:
- "${R2R_POSTGRES_PORT:-5432}:5432"
- "${R2R_POSTGRES_PORT:-5432}:${R2R_POSTGRES_PORT:-5432}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${R2R_POSTGRES_USER:-postgres}"]
interval: 10s
Expand Down
16 changes: 13 additions & 3 deletions py/core/main/api/ingestion_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ async def ingest_files_app(
"user": auth_user.model_dump_json(),
"size_in_bytes": content_length,
"collection_ids": (
collection_ids[it] if collection_ids else None
[str(cid) for cid in collection_ids[it]]
if collection_ids
else None
),
"is_update": False,
}
Expand Down Expand Up @@ -340,7 +342,11 @@ async def update_files_app(
"ingestion_config": ingestion_config,
"user": auth_user.model_dump_json(),
"is_update": True,
"collection_ids": collection_ids,
"collection_ids": (
[str(cid) for cid in collection_ids[it]]
if collection_ids
else None
),
}

if run_with_orchestration:
Expand Down Expand Up @@ -419,7 +425,11 @@ async def ingest_chunks_app(
"chunks": [chunk.model_dump() for chunk in chunks],
"metadata": metadata or {},
"user": auth_user.model_dump_json(),
"collection_ids": collection_ids,
"collection_ids": (
[str(cid) for cid in collection_ids]
if collection_ids
else None
),
}
if run_with_orchestration:
raw_message = await self.orchestration_provider.run_workflow(
Expand Down
2 changes: 1 addition & 1 deletion py/core/main/services/management_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ async def get_conversation(
branch_id: Optional[str] = None,
auth_user=None,
) -> Tuple[str, list[Message], list[dict]]:
return await self.logging_connection.get_conversation(
return await self.logging_connection.get_conversation( # type: ignore
conversation_id, branch_id
)

Expand Down
12 changes: 6 additions & 6 deletions py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ python-multipart = { version = "^0.0.9", optional = true }
pydantic = { extras = ["email"], version = "^2.8.2", optional = true }
pyjwt = { version = "^2.8.0", optional = true }
pyyaml = { version = "^6.0.1", optional = true }
sendgrid = { version = "^6.11.0", optional = true }
sqlalchemy = { version = "^2.0.30", optional = true }
supabase = { version = "^2.7.4", optional = true }
tokenizers = { version = "0.19", optional = true }
Expand All @@ -82,7 +83,6 @@ python-docx = { version = "^1.1.0", optional = true }
aiosmtplib = "^3.0.2"
types-aiofiles = "^24.1.0.20240626"
aiohttp = "^3.10.10"
sendgrid = "^6.11.0"

[tool.poetry.extras]
core = [
Expand All @@ -105,6 +105,7 @@ core = [
"pydantic",
"pyjwt",
"pyyaml",
"sendgrid",
"sqlalchemy",
"supabase",
"tokenizers",
Expand Down
18 changes: 12 additions & 6 deletions py/tests/integration/runner_sdk_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,9 +1731,12 @@ def test_conversation_history_sdk():
sys.exit(1)

for i, message in enumerate(conversation["results"]):
message_role = message[1].get("role")
message_content = message[1].get("content")

if (
message["role"] != messages[i]["role"]
or message["content"] != messages[i]["content"]
message_role != messages[i]["role"]
or message_content != messages[i]["content"]
):
print(
"Conversation history test failed: Incorrect message content or role"
Expand Down Expand Up @@ -1766,22 +1769,25 @@ def test_conversation_history_sdk():
sys.exit(1)

for i, message in enumerate(conversation["results"]):
message_role = message[1].get("role")
message_content = message[1].get("content")

if i < len(messages):
if (
message["role"] != messages[i]["role"]
or message["content"] != messages[i]["content"]
message_role != messages[i]["role"]
or message_content != messages[i]["content"]
):
print(
"Conversation history test failed: Incorrect message content or role"
)
sys.exit(1)
else:
if message["role"] != "assistant":
if message_role != "assistant":
print(
"Conversation history test failed: Incorrect message role for assistant response"
)
sys.exit(1)
if response["messages"][-1]["content"] != message["content"]:
if response["messages"][-1]["content"] != message_content:
print(
"Conversation history test failed: Incorrect assistant response content"
)
Expand Down

0 comments on commit 749a9c8

Please sign in to comment.