This commit is contained in:
Mason Daugherty 2025-07-29 15:43:32 -04:00
parent 27347cdcf5
commit 502dba4af8
No known key found for this signature in database
3 changed files with 10 additions and 7 deletions

View File

@ -803,5 +803,8 @@ content.extend([
- **"AIMessage has no attribute 'additional_kwargs'"** → Use ReasoningContentBlock instead - **"AIMessage has no attribute 'additional_kwargs'"** → Use ReasoningContentBlock instead
- **"ChatMessage not found"** → ChatMessage doesn't exist in V1, remove references - **"ChatMessage not found"** → ChatMessage doesn't exist in V1, remove references
- **Type errors with ResponseMetadata** → Add `# type: ignore[typeddict-unknown-key]` for extra fields - **Type errors with ResponseMetadata** → Use `.get()` instead of checking directly
- Bad: `assert result.response_metadata["model_name"] == MODEL_NAME # type: ignore[typeddict-not-required-key]`
- Good: `assert result.response_metadata.get("model_name") == MODEL_NAME`
- **Generator type mismatches** → Use `str()` conversion for text extraction from content blocks - **Generator type mismatches** → Use `str()` conversion for text extraction from content blocks

View File

@ -75,7 +75,7 @@ def _convert_content_blocks_to_ollama_format(
) )
# Skip other content block types that aren't supported # Skip other content block types that aren't supported
return text_content, images, tool_calls # type: ignore[return-value] return text_content, images, tool_calls
def _convert_human_message_v1(message: HumanMessageV1) -> dict[str, Any]: def _convert_human_message_v1(message: HumanMessageV1) -> dict[str, Any]:

View File

@ -94,7 +94,7 @@ class TestMessageConversion:
assert len(result.content) == 1 assert len(result.content) == 1
assert result.content[0]["type"] == "text" assert result.content[0]["type"] == "text"
assert result.content[0]["text"] == "Hello! How can I help you today?" assert result.content[0]["text"] == "Hello! How can I help you today?"
assert result.response_metadata["model_name"] == MODEL_NAME # type: ignore[typeddict-not-required-key] assert result.response_metadata.get("model_name") == MODEL_NAME
assert result.response_metadata.get("done") is True assert result.response_metadata.get("done") is True
def test_convert_chunk_to_v1(self) -> None: def test_convert_chunk_to_v1(self) -> None:
@ -157,10 +157,10 @@ class TestChatOllamaV1:
ls_params = llm._get_ls_params() ls_params = llm._get_ls_params()
assert ls_params["ls_provider"] == "ollama" # type: ignore[typeddict-not-required-key] assert ls_params.get("ls_provider") == "ollama"
assert ls_params["ls_model_name"] == MODEL_NAME # type: ignore[typeddict-not-required-key] assert ls_params.get("ls_model_name") == MODEL_NAME
assert ls_params["ls_model_type"] == "chat" # type: ignore[typeddict-not-required-key] assert ls_params.get("ls_model_type") == "chat"
assert ls_params["ls_temperature"] == 0.5 # type: ignore[typeddict-not-required-key] assert ls_params.get("ls_temperature") == 0.5
def test_bind_tools_basic(self) -> None: def test_bind_tools_basic(self) -> None:
"""Test basic tool binding functionality.""" """Test basic tool binding functionality."""