mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-15 18:24:07 +00:00
Fix: Add thought_signatures to VertexGeminiConfig and test
This commit is contained in:
@@ -1811,6 +1811,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
||||
functions: Optional[ChatCompletionToolCallFunctionChunk] = None
|
||||
thinking_blocks: Optional[List[ChatCompletionThinkingBlock]] = None
|
||||
reasoning_content: Optional[str] = None
|
||||
thought_signatures: Optional[Any] = None
|
||||
|
||||
for idx, candidate in enumerate(_candidates):
|
||||
if "content" not in candidate:
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import pytest
|
||||
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import VertexGeminiConfig
|
||||
from litellm import ModelResponse
|
||||
|
||||
def test_process_candidates_unbound_local_error_fix():
|
||||
# Setup
|
||||
candidates = [
|
||||
{
|
||||
"content": {
|
||||
"role": "model"
|
||||
# "parts" is missing intentionally to trigger the issue
|
||||
},
|
||||
"finishReason": "STOP"
|
||||
}
|
||||
]
|
||||
model_response = ModelResponse()
|
||||
|
||||
# Execution
|
||||
try:
|
||||
VertexGeminiConfig._process_candidates(
|
||||
_candidates=candidates,
|
||||
model_response=model_response,
|
||||
standard_optional_params={},
|
||||
cumulative_tool_call_index=0
|
||||
)
|
||||
except UnboundLocalError as e:
|
||||
pytest.fail(f"UnboundLocalError raised: {e}")
|
||||
except Exception as e:
|
||||
# Other exceptions might be okay if they are not UnboundLocalError,
|
||||
# but ideally it should pass without error or raise a specific error if parts are required.
|
||||
# However, the goal is to verify thought_signatures doesn't crash.
|
||||
pass
|
||||
|
||||
# Verify that we didn't crash with UnboundLocalError
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_process_candidates_unbound_local_error_fix()
|
||||
print("Test passed!")
|
||||
Reference in New Issue
Block a user