Skip to content

Commit

Permalink
use instead of for in Ollama (#1239)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 authored Dec 10, 2024
1 parent cb051b2 commit 87dd2cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def from_dict(cls, data: Dict[str, Any]) -> "OllamaChatGenerator":
return default_from_dict(cls, data)

def _message_to_dict(self, message: ChatMessage) -> Dict[str, str]:
return {"role": message.role.value, "content": message.content}
return {"role": message.role.value, "content": message.text}

def _build_message_from_ollama_response(self, ollama_response: ChatResponse) -> ChatMessage:
"""
Expand Down
8 changes: 4 additions & 4 deletions integrations/ollama/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_build_message_from_ollama_response(self):
observed = OllamaChatGenerator(model=model)._build_message_from_ollama_response(ollama_response)

assert observed.role == "assistant"
assert observed.content == "Hello! How are you today?"
assert observed.text == "Hello! How are you today?"

@pytest.mark.integration
def test_run(self):
Expand All @@ -121,7 +121,7 @@ def test_run(self):

assert isinstance(response, dict)
assert isinstance(response["replies"], list)
assert answer in response["replies"][0].content
assert answer in response["replies"][0].text

@pytest.mark.integration
def test_run_with_chat_history(self):
Expand All @@ -137,7 +137,7 @@ def test_run_with_chat_history(self):

assert isinstance(response, dict)
assert isinstance(response["replies"], list)
assert "Manchester" in response["replies"][-1].content or "Glasgow" in response["replies"][-1].content
assert "Manchester" in response["replies"][-1].text or "Glasgow" in response["replies"][-1].text

@pytest.mark.integration
def test_run_model_unavailable(self):
Expand Down Expand Up @@ -166,4 +166,4 @@ def test_run_with_streaming(self):

assert isinstance(response, dict)
assert isinstance(response["replies"], list)
assert "Manchester" in response["replies"][-1].content or "Glasgow" in response["replies"][-1].content
assert "Manchester" in response["replies"][-1].text or "Glasgow" in response["replies"][-1].text

0 comments on commit 87dd2cd

Please sign in to comment.