From 31ef97a5dcef5dae0184dba2459633e743060aec Mon Sep 17 00:00:00 2001 From: Ivan Leo Date: Wed, 18 Dec 2024 12:50:21 +0800 Subject: [PATCH] fix: fixing ruff errors --- instructor/client_vertexai.py | 8 +++----- instructor/process_response.py | 1 - tests/llm/test_vertexai/test_modes.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/instructor/client_vertexai.py b/instructor/client_vertexai.py index 51833a76e..33e131fb1 100644 --- a/instructor/client_vertexai.py +++ b/instructor/client_vertexai.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Type, Union, get_origin +from typing import Any, Union, get_origin from vertexai.preview.generative_models import ToolConfig # type: ignore import vertexai.generative_models as gm # type: ignore @@ -27,7 +27,7 @@ def _create_gemini_json_schema(model: BaseModel): return gemini_schema -def _create_vertexai_tool(models: Union[BaseModel, list[BaseModel], Type]) -> gm.Tool: +def _create_vertexai_tool(models: Union[BaseModel, list[BaseModel], type]) -> gm.Tool: # noqa: UP007 """Creates a tool with function declarations for single model or list of models""" # Handle Iterable case first if get_origin(models) is not None: @@ -35,8 +35,6 @@ def _create_vertexai_tool(models: Union[BaseModel, list[BaseModel], Type]) -> gm else: # Handle both single model and list of models model_list = models if isinstance(models, list) else [models] - - print(f"Debug - Model list: {[model.__name__ for model in model_list]}") declarations = [] for model in model_list: @@ -101,7 +99,7 @@ def vertexai_function_response_parser( ) -def vertexai_process_response(_kwargs: dict[str, Any], model: Union[BaseModel, list[BaseModel], Type]): +def vertexai_process_response(_kwargs: dict[str, Any], model: Union[BaseModel, list[BaseModel], type]): # noqa: UP007 messages: list[dict[str, str]] = _kwargs.pop("messages") contents = _vertexai_message_list_parser(messages) # type: ignore diff --git a/instructor/process_response.py b/instructor/process_response.py index 7c0722f1a..f44031ab0 100644 --- a/instructor/process_response.py +++ b/instructor/process_response.py @@ -500,7 +500,6 @@ def handle_vertexai_parallel_tools( ), "stream=True is not supported when using PARALLEL_TOOLS mode" from instructor.client_vertexai import vertexai_process_response - from instructor.dsl.parallel import VertexAIParallelModel # Extract concrete types before passing to vertexai_process_response model_types = list(get_types_array(response_model)) diff --git a/tests/llm/test_vertexai/test_modes.py b/tests/llm/test_vertexai/test_modes.py index e8a990c5b..f1ac89102 100644 --- a/tests/llm/test_vertexai/test_modes.py +++ b/tests/llm/test_vertexai/test_modes.py @@ -1,5 +1,5 @@ from itertools import product -from pydantic import BaseModel, Field +from pydantic import BaseModel import vertexai.generative_models as gm # type: ignore import pytest import instructor