Skip to content

Commit

Permalink
Merge branch 'main' into fix-weaviate-4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Oct 18, 2024
2 parents ba41fcd + f166d91 commit 965e2b7
Show file tree
Hide file tree
Showing 33 changed files with 119 additions and 51 deletions.
6 changes: 6 additions & 0 deletions integrations/amazon_bedrock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [integrations/amazon_bedrock-v1.0.5] - 2024-10-17

### 🚀 Features

- Add prefixes to supported model patterns to allow cross region model ids (#1127)

## [integrations/amazon_bedrock-v1.0.4] - 2024-10-16

### 🐛 Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion integrations/amazon_bedrock/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/amazon_bedrock-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -60,8 +61,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"

Expand Down
4 changes: 3 additions & 1 deletion integrations/amazon_sagemaker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/amazon_sagemaker-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -65,8 +66,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
4 changes: 3 additions & 1 deletion integrations/anthropic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/anthropic-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -60,8 +61,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"

Expand Down
4 changes: 3 additions & 1 deletion integrations/astra/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/astra-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -59,8 +60,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
3 changes: 3 additions & 0 deletions integrations/chroma/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/chroma-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -61,8 +62,10 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.9", "3.10"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = [
"pip",
"black>=23.1.0",
"mypy>=1.0.0",
"ruff>=0.0.243",
Expand Down
4 changes: 3 additions & 1 deletion integrations/cohere/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/cohere-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -60,8 +61,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = [
Expand Down
4 changes: 3 additions & 1 deletion integrations/deepeval/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/deepeval-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = ["coverage[toml]>=6.5", "pytest", "pytest-rerunfailures", "haystack-pydoc-tools"]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
Expand All @@ -55,8 +56,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
4 changes: 3 additions & 1 deletion integrations/elasticsearch/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/elasticsearch-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -61,8 +62,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:}", "black --check --diff {args:.}"]
Expand Down
4 changes: 3 additions & 1 deletion integrations/fastembed/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/fastembed-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -62,8 +63,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243", "numpy"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243", "numpy"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
4 changes: 3 additions & 1 deletion integrations/google_ai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/google_ai-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -58,8 +59,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
4 changes: 3 additions & 1 deletion integrations/google_vertex/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/google_vertex-v[0-9]*"'

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"coverage[toml]>=6.5",
"pytest",
Expand All @@ -59,8 +60,9 @@ docs = ["pydoc-markdown pydoc/config.yml"]
python = ["3.8", "3.9", "3.10", "3.11"]

[tool.hatch.envs.lint]
installer = "uv"
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VertexAIGeminiChatGenerator:
from haystack.dataclasses import ChatMessage
from haystack_integrations.components.generators.google_vertex import VertexAIGeminiChatGenerator
gemini_chat = VertexAIGeminiChatGenerator(project_id=project_id)
gemini_chat = VertexAIGeminiChatGenerator()
messages = [ChatMessage.from_user("Tell me the name of a movie")]
res = gemini_chat.run(messages)
Expand All @@ -50,7 +50,7 @@ def __init__(
self,
*,
model: str = "gemini-1.5-flash",
project_id: str,
project_id: Optional[str] = None,
location: Optional[str] = None,
generation_config: Optional[Union[GenerationConfig, Dict[str, Any]]] = None,
safety_settings: Optional[Dict[HarmCategory, HarmBlockThreshold]] = None,
Expand All @@ -65,7 +65,7 @@ def __init__(
Authenticates using Google Cloud Application Default Credentials (ADCs).
For more information see the official [Google documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc).
:param project_id: ID of the GCP project to use.
:param project_id: ID of the GCP project to use. By default, it is set during Google Cloud authentication.
:param model: Name of the model to use. For available models, see https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models.
:param location: The default location to use when making API calls, if not set uses us-central-1.
Defaults to None.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class VertexAIGeminiGenerator:
from haystack_integrations.components.generators.google_vertex import VertexAIGeminiGenerator
gemini = VertexAIGeminiGenerator(project_id=project_id)
gemini = VertexAIGeminiGenerator()
result = gemini.run(parts = ["What is the most interesting thing you know?"])
for answer in result["replies"]:
print(answer)
Expand All @@ -54,7 +54,7 @@ def __init__(
self,
*,
model: str = "gemini-1.5-flash",
project_id: str,
project_id: Optional[str] = None,
location: Optional[str] = None,
generation_config: Optional[Union[GenerationConfig, Dict[str, Any]]] = None,
safety_settings: Optional[Dict[HarmCategory, HarmBlockThreshold]] = None,
Expand All @@ -69,7 +69,7 @@ def __init__(
Authenticates using Google Cloud Application Default Credentials (ADCs).
For more information see the official [Google documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc).
:param project_id: ID of the GCP project to use.
:param project_id: ID of the GCP project to use. By default, it is set during Google Cloud authentication.
:param model: Name of the model to use. For available models, see https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models.
:param location: The default location to use when making API calls, if not set uses us-central-1.
:param generation_config: The generation config to use.
Expand Down
19 changes: 10 additions & 9 deletions integrations/google_vertex/tests/chat/test_gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ def test_init(mock_vertexai_init, _mock_generative_model):
@patch("haystack_integrations.components.generators.google_vertex.chat.gemini.GenerativeModel")
def test_to_dict(_mock_vertexai_init, _mock_generative_model):

gemini = VertexAIGeminiChatGenerator(
project_id="TestID123",
)
gemini = VertexAIGeminiChatGenerator()
assert gemini.to_dict() == {
"type": "haystack_integrations.components.generators.google_vertex.chat.gemini.VertexAIGeminiChatGenerator",
"init_parameters": {
"model": "gemini-1.5-flash",
"project_id": "TestID123",
"project_id": None,
"location": None,
"generation_config": None,
"safety_settings": None,
Expand Down Expand Up @@ -132,6 +130,7 @@ def test_to_dict_with_params(_mock_vertexai_init, _mock_generative_model):

gemini = VertexAIGeminiChatGenerator(
project_id="TestID123",
location="TestLocation",
generation_config=generation_config,
safety_settings=safety_settings,
tools=[tool],
Expand All @@ -144,7 +143,7 @@ def test_to_dict_with_params(_mock_vertexai_init, _mock_generative_model):
"init_parameters": {
"model": "gemini-1.5-flash",
"project_id": "TestID123",
"location": None,
"location": "TestLocation",
"generation_config": {
"temperature": 0.5,
"top_p": 0.5,
Expand Down Expand Up @@ -194,7 +193,7 @@ def test_from_dict(_mock_vertexai_init, _mock_generative_model):
{
"type": "haystack_integrations.components.generators.google_vertex.chat.gemini.VertexAIGeminiChatGenerator",
"init_parameters": {
"project_id": "TestID123",
"project_id": None,
"model": "gemini-1.5-flash",
"generation_config": None,
"safety_settings": None,
Expand All @@ -205,7 +204,7 @@ def test_from_dict(_mock_vertexai_init, _mock_generative_model):
)

assert gemini._model_name == "gemini-1.5-flash"
assert gemini._project_id == "TestID123"
assert gemini._project_id is None
assert gemini._safety_settings is None
assert gemini._tools is None
assert gemini._tool_config is None
Expand All @@ -221,6 +220,7 @@ def test_from_dict_with_param(_mock_vertexai_init, _mock_generative_model):
"type": "haystack_integrations.components.generators.google_vertex.chat.gemini.VertexAIGeminiChatGenerator",
"init_parameters": {
"project_id": "TestID123",
"location": "TestLocation",
"model": "gemini-1.5-flash",
"generation_config": {
"temperature": 0.5,
Expand Down Expand Up @@ -272,6 +272,7 @@ def test_from_dict_with_param(_mock_vertexai_init, _mock_generative_model):

assert gemini._model_name == "gemini-1.5-flash"
assert gemini._project_id == "TestID123"
assert gemini._location == "TestLocation"
assert gemini._safety_settings == {HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_ONLY_HIGH}
assert repr(gemini._tools) == repr([Tool(function_declarations=[GET_CURRENT_WEATHER_FUNC])])
assert isinstance(gemini._tool_config, ToolConfig)
Expand All @@ -296,7 +297,7 @@ def test_run(mock_generative_model):
ChatMessage.from_system("You are a helpful assistant"),
ChatMessage.from_user("What's the capital of France?"),
]
gemini = VertexAIGeminiChatGenerator(project_id="TestID123", location=None)
gemini = VertexAIGeminiChatGenerator()
response = gemini.run(messages=messages)

mock_model.send_message.assert_called_once()
Expand All @@ -321,7 +322,7 @@ def streaming_callback(_chunk: StreamingChunk) -> None:
nonlocal streaming_callback_called
streaming_callback_called = True

gemini = VertexAIGeminiChatGenerator(project_id="TestID123", location=None, streaming_callback=streaming_callback)
gemini = VertexAIGeminiChatGenerator(streaming_callback=streaming_callback)
messages = [
ChatMessage.from_system("You are a helpful assistant"),
ChatMessage.from_user("What's the capital of France?"),
Expand Down
Loading

0 comments on commit 965e2b7

Please sign in to comment.