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

removing from_dict/to_dict AWS tests #8840

Merged
Merged
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
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ extra-dependencies = [
"spacy-curated-transformers>=0.2,<=0.3",
"en-core-web-trf @ https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.8.0/en_core_web_trf-3.8.0-py3-none-any.whl",

# LLMetadataExtractor
"amazon-bedrock-haystack>=1.0.2",
"google-vertex-haystack>=2.0.0",


# Converters
"pypdf", # PyPDFToDocument
"pdfminer.six", # PDFMinerToDocument
Expand Down
75 changes: 0 additions & 75 deletions test/components/extractors/test_llm_metadata_extractor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from unittest.mock import MagicMock

import boto3
import pytest
from haystack import Document, Pipeline
from haystack.components.builders import PromptBuilder
Expand Down Expand Up @@ -88,44 +87,6 @@ def test_to_dict_openai(self, monkeypatch):
},
}

def test_to_dict_aws_bedrock(self, boto3_session_mock):
extractor = LLMMetadataExtractor(
prompt="some prompt that was used with the LLM {{document.content}}",
expected_keys=["key1", "key2"],
generator_api=LLMProvider.AWS_BEDROCK,
generator_api_params={"model": "meta.llama.test"},
raise_on_failure=True,
)
extractor_dict = extractor.to_dict()
assert extractor_dict == {
"type": "haystack.components.extractors.llm_metadata_extractor.LLMMetadataExtractor",
"init_parameters": {
"prompt": "some prompt that was used with the LLM {{document.content}}",
"generator_api": "aws_bedrock",
"generator_api_params": {
"aws_access_key_id": {"type": "env_var", "env_vars": ["AWS_ACCESS_KEY_ID"], "strict": False},
"aws_secret_access_key": {
"type": "env_var",
"env_vars": ["AWS_SECRET_ACCESS_KEY"],
"strict": False,
},
"aws_session_token": {"type": "env_var", "env_vars": ["AWS_SESSION_TOKEN"], "strict": False},
"aws_region_name": {"type": "env_var", "env_vars": ["AWS_DEFAULT_REGION"], "strict": False},
"aws_profile_name": {"type": "env_var", "env_vars": ["AWS_PROFILE"], "strict": False},
"model": "meta.llama.test",
"stop_words": [],
"generation_kwargs": {},
"streaming_callback": None,
"boto3_config": None,
"tools": None,
},
"expected_keys": ["key1", "key2"],
"page_range": None,
"raise_on_failure": True,
"max_workers": 3,
},
}

def test_from_dict_openai(self, monkeypatch):
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
extractor_dict = {
Expand All @@ -151,42 +112,6 @@ def test_from_dict_openai(self, monkeypatch):
assert extractor.prompt == "some prompt that was used with the LLM {{document.content}}"
assert extractor.generator_api == LLMProvider.OPENAI

def test_from_dict_aws_bedrock(self, boto3_session_mock):
extractor_dict = {
"type": "haystack.components.extractors.llm_metadata_extractor.LLMMetadataExtractor",
"init_parameters": {
"prompt": "some prompt that was used with the LLM {{document.content}}",
"generator_api": "aws_bedrock",
"generator_api_params": {
"aws_access_key_id": {"type": "env_var", "env_vars": ["AWS_ACCESS_KEY_ID"], "strict": False},
"aws_secret_access_key": {
"type": "env_var",
"env_vars": ["AWS_SECRET_ACCESS_KEY"],
"strict": False,
},
"aws_session_token": {"type": "env_var", "env_vars": ["AWS_SESSION_TOKEN"], "strict": False},
"aws_region_name": {"type": "env_var", "env_vars": ["AWS_DEFAULT_REGION"], "strict": False},
"aws_profile_name": {"type": "env_var", "env_vars": ["AWS_PROFILE"], "strict": False},
"model": "meta.llama.test",
"stop_words": [],
"generation_kwargs": {},
"streaming_callback": None,
"boto3_config": None,
"tools": None,
},
"expected_keys": ["key1", "key2"],
"page_range": None,
"raise_on_failure": True,
"max_workers": 3,
},
}
extractor = LLMMetadataExtractor.from_dict(extractor_dict)
assert extractor.raise_on_failure is True
assert extractor.expected_keys == ["key1", "key2"]
assert extractor.prompt == "some prompt that was used with the LLM {{document.content}}"
assert extractor.generator_api == LLMProvider.AWS_BEDROCK
assert extractor.llm_provider.model == "meta.llama.test"

def test_warm_up(self, monkeypatch):
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
extractor = LLMMetadataExtractor(prompt="prompt {{document.content}}", generator_api=LLMProvider.OPENAI)
Expand Down
Loading