The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge branch 'litellm_internal_staging' of https://github.com/BerriAI/litellm into litellm_together_reasoning_effort
mateo-berrid8eac99bb996
diff --cc litellm/llms/together_ai/chat/transformation.pyindex 6d5c84a2da3,6bf53ee348b..cb630711ffe--- a/litellm/llms/together_ai/chat/transformation.py+++ b/litellm/llms/together_ai/chat/transformation.py@@@ -4,16 -4,20 +4,22 @@@ Translates from OpenAI's `/v1/chat/compDocs: https://docs.together.ai/docs/chat-overview"""- from collections.abc import Container, Mapping-from collections.abc import Container, Coroutine++from collections.abc import Container, Coroutine, Mappingfrom types import MappingProxyType- from typing import Final+ from typing import (+ Final,+ Literal,+ cast, # noqa: TID251 # rebuilding a TypedDict minus keys has no checked spelling+ overload,+ )+from typing_extensions import ReadOnly, TypedDict+import litellmfrom litellm._logging import verbose_loggerfrom litellm.exceptions import UnsupportedParamsError+ from litellm.types.llms.openai import AllMessageValues-from litellm.utils import supports_function_calling+from litellm.utils import supports_function_calling, supports_reasoningfrom ...openai.chat.gpt_transformation import OpenAIGPTConfig@@@ -90,37 -68,50 +97,80 @@@ def _tool_params_to_drop(passed_params)+def _supports_together_reasoning(model: str) -> bool:+ if model in ADJUSTABLE_EFFORT_REASONING_MODELS or model in HYBRID_REASONING_MODELS:+ return True+ if model.startswith(HIGH_MAX_EFFORT_MODEL_PREFIX):+ return True+ return supports_reasoning(model, custom_llm_provider="together_ai")+++def _adjustable_effort(effort: str, model: str) -> str:+ if effort == "none":+ verbose_logger.debug(+ "together_ai model %s cannot disable reasoning; mapping reasoning_effort=none to low", model+ )+ return "low"+ return EFFORT_TRANSLATION.get(effort, effort)+++def _reasoning_effort_payload(effort: str, model: str) -> Mapping[str, object]:+ if effort == "default":+ return MappingProxyType({})+ if model in ADJUSTABLE_EFFORT_REASONING_MODELS:+ return MappingProxyType({"reasoning_effort": _adjustable_effort(effort, model)})+ if effort == "none":+ disable_reasoning: Final[TogetherReasoningToggle] = {"enabled": False}+ return MappingProxyType({"reasoning": disable_reasoning})+ if model.startswith(HIGH_MAX_EFFORT_MODEL_PREFIX):+ return MappingProxyType({"reasoning_effort": HIGH_MAX_EFFORT_TRANSLATION.get(effort, effort)})+ return MappingProxyType({"reasoning_effort": EFFORT_TRANSLATION.get(effort, effort)})+++ def _without_litellm_internal_fields(message: AllMessageValues) -> AllMessageValues:+ if message["role"] != "assistant" or LITELLM_INTERNAL_ASSISTANT_FIELDS.isdisjoint(message):+ return message+ return cast( # cast-ok: rebuilding the same TypedDict minus internal keys loses the narrowed type+ "AllMessageValues",+ { # mutable-ok: TypedDict rebuild minus internal keys+ key: value for key, value in message.items() if key not in LITELLM_INTERNAL_ASSISTANT_FIELDS+ },+ )++class TogetherAIChatConfig(OpenAIGPTConfig):+ @overload+ def _transform_messages(+ self,+ messages: list[AllMessageValues], # mutable-ok: inherited contract+ model: str,+ is_async: Literal[True],+ ) -> Coroutine[object, object, list[AllMessageValues]]: ... # mutable-ok: inherited contract++ @overload+ def _transform_messages(+ self,+ messages: list[AllMessageValues], # mutable-ok: inherited contract+ model: str,+ is_async: Literal[False] = False,+ ) -> list[AllMessageValues]: ... # mutable-ok: inherited contract++ def _transform_messages(+ self,+ messages: list[AllMessageValues], # mutable-ok: inherited contract+ model: str,+ is_async: bool = False,+ ) -> list[AllMessageValues] | Coroutine[object, object, list[AllMessageValues]]: # mutable-ok: inherited contract+ """Together consumes replayed assistant `reasoning_content` (preserved thinking via+ `chat_template_kwargs: {"clear_thinking": false}`), so it must stay in the payload;+ only litellm-internal fields are stripped before sending."""+ stripped: Final = [ # mutable-ok: super() requires a list+ _without_litellm_internal_fields(message) for message in messages+ ]+ if is_async:+ return super()._transform_messages(stripped, model, is_async=True)+ return super()._transform_messages(stripped, model, is_async=False)+def get_supported_openai_params(self, model: str) -> list:supports_fc: Final = _function_calling_verdict(model)supported_params: Final = super().get_supported_openai_params(model)