Skip to content
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
10 changes: 2 additions & 8 deletions integrations/togetherai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "togetherai-haystack"
dynamic = ["version"]
description = 'An integration between the Together AI framework and Haystack'
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = "Apache-2.0"
keywords = []
authors = [{ name = "deepset GmbH", email = "[email protected]" }]
Expand All @@ -16,15 +16,14 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["haystack-ai>=2.19.0"]
dependencies = ["haystack-ai>=2.22.0"]

[project.urls]
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/togetherai#readme"
Expand Down Expand Up @@ -84,7 +83,6 @@ known-first-party = ["haystack_integrations"]


[tool.ruff]
target-version = "py39"
line-length = 120

[tool.ruff.lint]
Expand Down Expand Up @@ -131,10 +129,6 @@ ignore = [
"B008",
"S101",
]
unfixable = [
# Don't touch unused imports
"F401",
]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Any, Optional
from typing import Any

from haystack import component, default_to_dict, logging
from haystack.components.generators.chat import OpenAIChatGenerator
Expand Down Expand Up @@ -63,13 +63,13 @@ def __init__(
*,
api_key: Secret = Secret.from_env_var("TOGETHER_API_KEY"),
model: str = "meta-llama/Llama-3.3-70B-Instruct-Turbo",
streaming_callback: Optional[StreamingCallbackT] = None,
api_base_url: Optional[str] = "https://api.together.xyz/v1",
generation_kwargs: Optional[dict[str, Any]] = None,
tools: Optional[ToolsType] = None,
timeout: Optional[float] = None,
max_retries: Optional[int] = None,
http_client_kwargs: Optional[dict[str, Any]] = None,
streaming_callback: StreamingCallbackT | None = None,
api_base_url: str | None = "https://api.together.xyz/v1",
generation_kwargs: dict[str, Any] | None = None,
tools: ToolsType | None = None,
timeout: float | None = None,
max_retries: int | None = None,
http_client_kwargs: dict[str, Any] | None = None,
):
"""
Creates an instance of TogetherAIChatGenerator. Unless specified otherwise,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

from typing import Any, Optional, Union, cast
from typing import Any, cast

from haystack import component, default_to_dict, logging
from haystack.dataclasses import ChatMessage, StreamingCallbackT
Expand Down Expand Up @@ -35,12 +35,12 @@ def __init__(
self,
api_key: Secret = Secret.from_env_var("TOGETHER_API_KEY"),
model: str = "meta-llama/Llama-3.3-70B-Instruct-Turbo",
api_base_url: Optional[str] = "https://api.together.xyz/v1",
streaming_callback: Optional[StreamingCallbackT] = None,
system_prompt: Optional[str] = None,
generation_kwargs: Optional[dict[str, Any]] = None,
timeout: Optional[float] = None,
max_retries: Optional[int] = None,
api_base_url: str | None = "https://api.together.xyz/v1",
streaming_callback: StreamingCallbackT | None = None,
system_prompt: str | None = None,
generation_kwargs: dict[str, Any] | None = None,
timeout: float | None = None,
max_retries: int | None = None,
):
"""
Initialize the TogetherAIGenerator.
Expand Down Expand Up @@ -141,9 +141,9 @@ def run( # type: ignore[override]
self,
*,
prompt: str,
system_prompt: Optional[str] = None,
streaming_callback: Optional[StreamingCallbackT] = None,
generation_kwargs: Optional[dict[str, Any]] = None,
system_prompt: str | None = None,
streaming_callback: StreamingCallbackT | None = None,
generation_kwargs: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""
Generate text completions synchronously.
Expand Down Expand Up @@ -179,9 +179,9 @@ async def run_async( # type: ignore[override]
self,
*,
prompt: str,
system_prompt: Optional[str] = None,
streaming_callback: Optional[StreamingCallbackT] = None,
generation_kwargs: Optional[dict[str, Any]] = None,
system_prompt: str | None = None,
streaming_callback: StreamingCallbackT | None = None,
generation_kwargs: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""
Generate text completions asynchronously.
Expand Down Expand Up @@ -211,7 +211,7 @@ async def run_async( # type: ignore[override]
replies = chat_response["replies"]
return self._convert_chat_response_to_generator_format(replies)

def _prepare_messages(self, prompt: str, system_prompt: Optional[str] = None) -> list[ChatMessage]:
def _prepare_messages(self, prompt: str, system_prompt: str | None = None) -> list[ChatMessage]:
"""
Convert prompt and system_prompt to ChatMessage format.

Expand All @@ -228,7 +228,7 @@ def _prepare_messages(self, prompt: str, system_prompt: Optional[str] = None) ->

def _convert_chat_response_to_generator_format(
self, chat_messages: list[ChatMessage]
) -> dict[str, Union[list[str], list[dict[str, Any]]]]:
) -> dict[str, list[str] | list[dict[str, Any]]]:
"""
Convert ChatGenerator response format to Generator format.

Expand Down
Loading