From 70770b6aa4643453fd27ef7a8f1c47d9cd2cfffd Mon Sep 17 00:00:00 2001 From: Sunny Wan Date: Thu, 13 Mar 2025 19:42:10 -0400 Subject: [PATCH] Removed unnecessary code and refactored --- litellm/__init__.py | 4 +- litellm/llms/snowflake/chat/transformation.py | 43 +------------------ 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 86c75d8b14..55a185e571 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -821,7 +821,7 @@ from .llms.databricks.embed.transformation import DatabricksEmbeddingConfig from .llms.predibase.chat.transformation import PredibaseConfig from .llms.replicate.chat.transformation import ReplicateConfig from .llms.cohere.completion.transformation import CohereTextConfig as CohereConfig -from .llms.snowflake.completion.transformation import SnowflakeConfig +from .llms.snowflake.chat.transformation import SnowflakeConfig from .llms.cohere.rerank.transformation import CohereRerankConfig from .llms.cohere.rerank_v2.transformation import CohereRerankV2Config from .llms.azure_ai.rerank.transformation import AzureAIRerankConfig @@ -936,7 +936,7 @@ from .llms.openai.chat.o_series_transformation import ( OpenAIOSeriesConfig, ) -from .llms.snowflake.completion.transformation import SnowflakeConfig +from .llms.snowflake.chat.transformation import SnowflakeConfig openaiOSeriesConfig = OpenAIOSeriesConfig() from .llms.openai.chat.gpt_transformation import ( diff --git a/litellm/llms/snowflake/chat/transformation.py b/litellm/llms/snowflake/chat/transformation.py index 48593cf0db..7700607958 100644 --- a/litellm/llms/snowflake/chat/transformation.py +++ b/litellm/llms/snowflake/chat/transformation.py @@ -59,34 +59,6 @@ class SnowflakeConfig(OpenAIGPTConfig): if param in supported_openai_params: optional_params[param] = value return optional_params - - def _convert_tool_response_to_message( - message: ChatCompletionAssistantMessage, json_mode: bool - ) -> ChatCompletionAssistantMessage: - """ - if json_mode is true, convert the returned tool call response to a content with json str - - e.g. input: - - {"role": "assistant", "tool_calls": [{"id": "call_5ms4", "type": "function", "function": {"name": "json_tool_call", "arguments": "{\"key\": \"question\", \"value\": \"What is the capital of France?\"}"}}]} - - output: - - {"role": "assistant", "content": "{\"key\": \"question\", \"value\": \"What is the capital of France?\"}"} - """ - if not json_mode: - return message - - _tool_calls = message.get("tool_calls") - - if _tool_calls is None or len(_tool_calls) != 1: - return message - - message["content"] = _tool_calls[0]["function"].get("arguments") or "" - message["tool_calls"] = None - - return message - @staticmethod def transform_response( @@ -110,12 +82,6 @@ class SnowflakeConfig(OpenAIGPTConfig): additional_args={"complete_input_dict": request_data}, ) - if json_mode: - for choice in response_json["choices"]: - message = SnowflakeConfig._convert_tool_response_to_message( - choice.get("message"), json_mode - ) - choice["message"] = message returned_response = ModelResponse(**response_json) @@ -207,11 +173,4 @@ class SnowflakeConfig(OpenAIGPTConfig): "stream": stream, **optional_params, **extra_body, - } - - def get_model_response_iterator( - self, - streaming_response: ModelResponse, - sync_stream: bool, - ): - return ModelResponseIterator(streaming_response=streaming_response, sync_stream=sync_stream) \ No newline at end of file + } \ No newline at end of file