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

fix: Add error message for use_advanced_pdf_parsing with Slack or Jira #4248

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions tests/unit/vertex_rag/test_rag_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ def test_prepare_import_files_request_slack_source(self):
)
import_files_request_eq(request, tc.TEST_IMPORT_REQUEST_SLACK_SOURCE)

def test_prepare_import_slack_request_advanced_pdf_parsing_enabled_error(self):
with pytest.raises(ValueError) as e:
rag.import_files(
corpus_name=tc.TEST_RAG_CORPUS_RESOURCE_NAME,
source=tc.TEST_SLACK_SOURCE,
chunk_size=tc.TEST_CHUNK_SIZE,
chunk_overlap=tc.TEST_CHUNK_OVERLAP,
use_advanced_pdf_parsing=True,
)
e.match("use_advanced_pdf_parsing is not supported for Slack or Jira")

def test_prepare_import_files_request_jira_source(self):
request = prepare_import_files_request(
corpus_name=tc.TEST_RAG_CORPUS_RESOURCE_NAME,
Expand All @@ -462,6 +473,17 @@ def test_prepare_import_files_request_jira_source(self):
)
import_files_request_eq(request, tc.TEST_IMPORT_REQUEST_JIRA_SOURCE)

def test_prepare_import_jira_request_advanced_pdf_parsing_enabled_error(self):
with pytest.raises(ValueError) as e:
rag.import_files(
corpus_name=tc.TEST_RAG_CORPUS_RESOURCE_NAME,
source=tc.TEST_JIRA_SOURCE,
chunk_size=tc.TEST_CHUNK_SIZE,
chunk_overlap=tc.TEST_CHUNK_OVERLAP,
use_advanced_pdf_parsing=True,
)
e.match("use_advanced_pdf_parsing is not supported for Slack or Jira")

def test_set_embedding_model_config_set_both_error(self):
embedding_model_config = rag.EmbeddingModelConfig(
publisher_model="whatever",
Expand Down
4 changes: 4 additions & 0 deletions vertexai/preview/rag/rag_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def import_files(
raise ValueError("Only one of source or paths must be passed in at a time")
if source is None and paths is None:
raise ValueError("One of source or paths must be passed in")
if use_advanced_pdf_parsing and source is not None:
raise ValueError("use_advanced_pdf_parsing is not supported for Slack or Jira")
corpus_name = _gapic_utils.get_corpus_name(corpus_name)
request = _gapic_utils.prepare_import_files_request(
corpus_name=corpus_name,
Expand Down Expand Up @@ -493,6 +495,8 @@ async def import_files_async(
raise ValueError("Only one of source or paths must be passed in at a time")
if source is None and paths is None:
raise ValueError("One of source or paths must be passed in")
if use_advanced_pdf_parsing and source is not None:
raise ValueError("use_advanced_pdf_parsing is not supported for Slack or Jira")
corpus_name = _gapic_utils.get_corpus_name(corpus_name)
request = _gapic_utils.prepare_import_files_request(
corpus_name=corpus_name,
Expand Down