Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REDBOX 337 chat file selection #556

Merged
merged 32 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
faed993
Add ChatMessage many-to-many relation to File, and make them availabl…
brunns Jun 7, 2024
3add66a
Show selected files on chats page.
brunns Jun 7, 2024
1b8e317
Save selected file, and send to core, for streamed chat version.
brunns Jun 7, 2024
f7ff925
Use checkboxes for selecting files
KevinEtchells Jun 7, 2024
3eb716f
Move "Files to use" to sidebar
KevinEtchells Jun 7, 2024
bffcb44
Tests for saving & sending selected files.
brunns Jun 10, 2024
cf63656
Setup document selection for streaming client-side
KevinEtchells Jun 10, 2024
2c913e0
Save selected file, and send to core, for streamed chat version.
brunns Jun 10, 2024
c4aa4f3
Enable chat streaming in all tests.
brunns Jun 7, 2024
8c254cc
add eval results visualisation and calculate uncertainity
esoutter Jun 7, 2024
6b14a74
remove inline outputs
esoutter Jun 7, 2024
e8562eb
Address Will's PR comments
esoutter Jun 7, 2024
f842c3e
Remove streaming demo
KevinEtchells Jun 10, 2024
26b199d
Save non-rag responses to DB - tactical fix.
brunns Jun 10, 2024
99252a2
Revert tactical fix - we are doing it properly here.
brunns Jun 10, 2024
0f1bfe6
Recieve selected file list in core API for streaming.
brunns Jun 10, 2024
4fe6d67
Merge branch 'main' into feature/REDBOX-337-chat-file-selection
brunns Jun 10, 2024
6fab42f
Merge branch 'main' into feature/REDBOX-337-chat-file-selection
brunns Jun 10, 2024
0a5c6aa
Add selected files to e2e tests.
brunns Jun 10, 2024
f7d555a
Bug - ensure latest question is always the one answered.
brunns Jun 10, 2024
3f9c028
Merge branch 'main' into feature/REDBOX-337-chat-file-selection
brunns Jun 10, 2024
117b152
Unit tests not working but the core plumbing is there
Jun 10, 2024
00f8d44
Merge branch 'main' into feature/REDBOX-337-chat-file-selection
brunns Jun 11, 2024
aa66c80
Post merge formatting.
brunns Jun 11, 2024
bfb193e
wip
Jun 11, 2024
9a4a3bb
test now passing
Jun 11, 2024
28d72a2
Add some logging for debug purposes.
brunns Jun 11, 2024
6a9fc15
Merge branch 'main' into feature/REDBOX-337-chat-file-selection
brunns Jun 11, 2024
b70ff2d
must != should
Jun 11, 2024
50ba97e
remove change made in error
Jun 11, 2024
a7a658a
migration test added
Jun 11, 2024
bd368c0
no longer changing source_files
Jun 12, 2024
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
7 changes: 5 additions & 2 deletions core_api/src/routes/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ async def build_retrieval_chain(

search_kwargs = {"filter": {"bool": {"must": [{"term": {"creator_user_uuid.keyword": str(user_uuid)}}]}}}

if chat_request.selected_files is not None:
search_kwargs["filter"]["bool"]["should"] = [
if chat_request.selected_files:
logging.info("chat_request.selected_files: %s", str(chat_request.selected_files))
search_kwargs["filter"]["bool"]["must"] = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

shoot me

{"term": {"parent_file_uuid.keyword": str(file.uuid)}} for file in chat_request.selected_files
]

Expand Down Expand Up @@ -152,6 +153,8 @@ async def rag_chat(
StreamingResponse: a stream of the chain response
"""

logging.info("chat_request: %s", chat_request)

question = chat_request.message_history[-1].text
route = route_layer(question)

Expand Down
6 changes: 3 additions & 3 deletions infrastructure/aws/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module "django-app" {
create_networking = true
source = "../../../i-ai-core-infrastructure//modules/ecs"
name = "${local.name}-django-app"
image_tag = var.image_tag
image_tag = "9a4a3bbeda7e464bfe87a0588b7ee0d310e8e98d"
ecr_repository_uri = "${var.ecr_repository_uri}/${var.project_name}-django-app"
ecs_cluster_id = module.cluster.ecs_cluster_id
ecs_cluster_name = module.cluster.ecs_cluster_name
Expand Down Expand Up @@ -80,7 +80,7 @@ module "core_api" {
create_networking = false
source = "../../../i-ai-core-infrastructure//modules/ecs"
name = "${local.name}-core-api"
image_tag = var.image_tag
image_tag = "9a4a3bbeda7e464bfe87a0588b7ee0d310e8e98d"
ecr_repository_uri = "${var.ecr_repository_uri}/redbox-core-api"
ecs_cluster_id = module.cluster.ecs_cluster_id
ecs_cluster_name = module.cluster.ecs_cluster_name
Expand Down Expand Up @@ -111,7 +111,7 @@ module "worker" {
create_networking = false
source = "../../../i-ai-core-infrastructure//modules/ecs"
name = "${local.name}-worker"
image_tag = var.image_tag
image_tag = "9a4a3bbeda7e464bfe87a0588b7ee0d310e8e98d"
ecr_repository_uri = "${var.ecr_repository_uri}/redbox-worker"
ecs_cluster_id = module.cluster.ecs_cluster_id
ecs_cluster_name = module.cluster.ecs_cluster_name
Expand Down
26 changes: 26 additions & 0 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,32 @@ def test_post_rag(self, user_uuid):
assert TestEndToEnd.file_uuids[user_uuid] in source_document_file_uuids
TestEndToEnd.source_document_file_uuids[user_uuid] = source_document_file_uuids

@pytest.mark.parametrize("user_uuid", USER_UUIDS)
def test_post_rag_fail(self, user_uuid):
"""
Given that I have POSTed a file key to core-api/file
And the file status is complete
When I POST a question to the rag endpoint with the wrong file selected
I Expect an answer and for no cited documents to be returned
"""
rag_response = requests.post(
"http://localhost:5002/chat/rag",
json={
"message_history": [
{"role": "user", "text": "what is routing?"},
],
"selected_files": [{"uuid": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],
},
headers=make_headers(user_uuid),
timeout=30,
)
assert rag_response.status_code == HTTPStatus.OK

source_document_file_uuids = {
source_document["file_uuid"] for source_document in rag_response.json()["source_documents"]
}
assert TestEndToEnd.file_uuids[user_uuid] not in source_document_file_uuids

@pytest.mark.parametrize("user_uuid", USER_UUIDS)
def test_permissions(self, user_uuid):
"""
Expand Down
Loading