|
4 | 4 | import re
|
5 | 5 | import tempfile
|
6 | 6 | from pathlib import Path
|
7 |
| -from typing import Any |
8 | 7 |
|
9 | 8 | import pytest
|
10 |
| -from httpx import Response as httpxResponse |
11 | 9 | from pydantic import BaseModel, ValidationError
|
12 | 10 | from pytest_httpserver import HTTPServer, URIPattern
|
13 | 11 | from werkzeug.wrappers import Request, Response
|
14 | 12 |
|
15 | 13 | from ollama._client import CONNECTION_ERROR_MESSAGE, AsyncClient, Client, _copy_tools
|
16 |
| -from ollama._types import Image, Message |
| 14 | +from ollama._types import Image |
17 | 15 |
|
18 | 16 | PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYGAAAAAEAAH2FzhVAAAAAElFTkSuQmCC'
|
19 | 17 | PNG_BYTES = base64.b64decode(PNG_BASE64)
|
@@ -1183,32 +1181,3 @@ async def test_async_client_connection_error():
|
1183 | 1181 | with pytest.raises(ConnectionError) as exc_info:
|
1184 | 1182 | await client.show('model')
|
1185 | 1183 | assert str(exc_info.value) == 'Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download'
|
1186 |
| - |
1187 |
| - |
1188 |
| -def test_arbitrary_roles_accepted_in_message(): |
1189 |
| - _ = Message(role='somerandomrole', content="I'm ok with you adding any role message now!") |
1190 |
| - |
1191 |
| - |
1192 |
| -def _mock_request(*args: Any, **kwargs: Any) -> Response: |
1193 |
| - return httpxResponse(status_code=200, content="{'response': 'Hello world!'}") |
1194 |
| - |
1195 |
| - |
1196 |
| -def test_arbitrary_roles_accepted_in_message_request(monkeypatch: pytest.MonkeyPatch): |
1197 |
| - monkeypatch.setattr(Client, '_request', _mock_request) |
1198 |
| - |
1199 |
| - client = Client() |
1200 |
| - |
1201 |
| - client.chat(model='llama3.1', messages=[{'role': 'somerandomrole', 'content': "I'm ok with you adding any role message now!"}, {'role': 'user', 'content': 'Hello world!'}]) |
1202 |
| - |
1203 |
| - |
1204 |
| -async def _mock_request_async(*args: Any, **kwargs: Any) -> Response: |
1205 |
| - return httpxResponse(status_code=200, content="{'response': 'Hello world!'}") |
1206 |
| - |
1207 |
| - |
1208 |
| -@pytest.mark.asyncio |
1209 |
| -async def test_arbitrary_roles_accepted_in_message_request_async(monkeypatch: pytest.MonkeyPatch): |
1210 |
| - monkeypatch.setattr(AsyncClient, '_request', _mock_request_async) |
1211 |
| - |
1212 |
| - client = AsyncClient() |
1213 |
| - |
1214 |
| - await client.chat(model='llama3.1', messages=[{'role': 'somerandomrole', 'content': "I'm ok with you adding any role message now!"}, {'role': 'user', 'content': 'Hello world!'}]) |
0 commit comments