mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-14 06:24:53 +00:00
Removed unnecessary code and refactored
This commit is contained in:
+2
-2
@@ -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 (
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user