Repository navigation
fix(together_ai): route chat completions through a dedicated TogetherAIChatConfig #38248
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
Merged
mateo-berri
merged 2 commits into
litellm_internal_staging
from
litellm_together_chat_config
Aug 25, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from .transformation import TogetherAIChatConfig as TogetherAIChatConfig | ||
|
|
||
| TogetherAIConfig = TogetherAIChatConfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Translates from OpenAI's `/v1/chat/completions` to Together AI's `/v1/chat/completions`. | ||
|
|
||
| Docs: https://docs.together.ai/docs/chat-overview | ||
| """ | ||
|
|
||
| from types import MappingProxyType | ||
| from typing import Final | ||
|
|
||
| from litellm._logging import verbose_logger | ||
| from litellm.utils import supports_function_calling | ||
|
|
||
| from ...openai.chat.gpt_transformation import OpenAIGPTConfig | ||
|
|
||
| FUNCTION_CALLING_ONLY_PARAMS: Final = ("tools", "tool_choice", "function_call", "response_format") | ||
| PLAIN_TEXT_RESPONSE_FORMAT: Final = MappingProxyType({"type": "text"}) | ||
|
|
||
|
|
||
| class TogetherAIChatConfig(OpenAIGPTConfig): | ||
| def get_supported_openai_params(self, model: str) -> list: | ||
| supports_fc: bool | None = None | ||
| try: | ||
| supports_fc = supports_function_calling(model, custom_llm_provider="together_ai") | ||
| except Exception as e: | ||
| verbose_logger.debug("Error getting supported openai params: %s", e) | ||
|
|
||
| supported_params: Final = super().get_supported_openai_params(model) | ||
| if supports_fc is True: | ||
| return supported_params | ||
| verbose_logger.debug( | ||
| "Only some together models support function calling/response_format. Docs - https://docs.together.ai/docs/function-calling" | ||
| ) | ||
| return [ # mutable-ok: the inherited contract returns a plain list; building fresh avoids mutating the base class's value | ||
| param for param in supported_params if param not in FUNCTION_CALLING_ONLY_PARAMS | ||
| ] | ||
|
|
||
| def map_openai_params( | ||
| self, | ||
| non_default_params: dict, | ||
| optional_params: dict, | ||
| model: str, | ||
| drop_params: bool, | ||
| ) -> dict: | ||
| mapped_openai_params: Final = super().map_openai_params(non_default_params, optional_params, model, drop_params) | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| if mapped_openai_params.get("response_format") == PLAIN_TEXT_RESPONSE_FORMAT: | ||
| mapped_openai_params.pop("response_format") | ||
| return mapped_openai_params | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.