mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
ollama[patch]: ruff fixes and rules (#31924)
* bump ruff deps * add more thorough ruff rules * fix said rules
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Ollama specific chat model integration tests"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated, Optional
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -21,8 +21,7 @@ def get_current_weather(location: str) -> dict:
|
||||
"""Gets the current weather in a given location."""
|
||||
if "boston" in location.lower():
|
||||
return {"temperature": "15°F", "conditions": "snow"}
|
||||
else:
|
||||
return {"temperature": "unknown", "conditions": "unknown"}
|
||||
return {"temperature": "unknown", "conditions": "unknown"}
|
||||
|
||||
|
||||
class TestChatOllama(ChatModelIntegrationTests):
|
||||
@@ -65,16 +64,15 @@ class TestChatOllama(ChatModelIntegrationTests):
|
||||
|
||||
if chunk.tool_call_chunks:
|
||||
tool_chunk_found = True
|
||||
for tc_chunk in chunk.tool_call_chunks:
|
||||
collected_tool_chunks.append(tc_chunk)
|
||||
collected_tool_chunks.extend(chunk.tool_call_chunks)
|
||||
|
||||
if chunk.tool_calls:
|
||||
final_tool_calls.extend(chunk.tool_calls)
|
||||
|
||||
assert tool_chunk_found, "Tool streaming did not produce any tool_call_chunks."
|
||||
assert (
|
||||
len(final_tool_calls) == 1
|
||||
), f"Expected 1 final tool call, but got {len(final_tool_calls)}"
|
||||
assert len(final_tool_calls) == 1, (
|
||||
f"Expected 1 final tool call, but got {len(final_tool_calls)}"
|
||||
)
|
||||
|
||||
final_tool_call = final_tool_calls[0]
|
||||
assert final_tool_call["name"] == "get_current_weather"
|
||||
@@ -110,16 +108,15 @@ class TestChatOllama(ChatModelIntegrationTests):
|
||||
|
||||
if chunk.tool_call_chunks:
|
||||
tool_chunk_found = True
|
||||
for tc_chunk in chunk.tool_call_chunks:
|
||||
collected_tool_chunks.append(tc_chunk)
|
||||
collected_tool_chunks.extend(chunk.tool_call_chunks)
|
||||
|
||||
if chunk.tool_calls:
|
||||
final_tool_calls.extend(chunk.tool_calls)
|
||||
|
||||
assert tool_chunk_found, "Tool streaming did not produce any tool_call_chunks."
|
||||
assert (
|
||||
len(final_tool_calls) == 1
|
||||
), f"Expected 1 final tool call, but got {len(final_tool_calls)}"
|
||||
assert len(final_tool_calls) == 1, (
|
||||
f"Expected 1 final tool call, but got {len(final_tool_calls)}"
|
||||
)
|
||||
|
||||
final_tool_call = final_tool_calls[0]
|
||||
assert final_tool_call["name"] == "get_current_weather"
|
||||
|
||||
@@ -4,4 +4,3 @@ import pytest
|
||||
@pytest.mark.compile
|
||||
def test_placeholder() -> None:
|
||||
"""Used for compiling integration tests without running any real tests."""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user