mirror of
https://github.com/ollama/ollama-python.git
synced 2026-08-31 08:49:54 +00:00
Merge pull request #158 from tillfalko/main
Avoid side effects if chat message contains images
This commit is contained in:
@@ -7,6 +7,7 @@ import platform
|
|||||||
import urllib.parse
|
import urllib.parse
|
||||||
from os import PathLike
|
from os import PathLike
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from copy import deepcopy
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from base64 import b64encode, b64decode
|
from base64 import b64encode, b64decode
|
||||||
|
|
||||||
@@ -164,6 +165,8 @@ class Client(BaseClient):
|
|||||||
if not model:
|
if not model:
|
||||||
raise RequestError('must provide a model')
|
raise RequestError('must provide a model')
|
||||||
|
|
||||||
|
messages = deepcopy(messages)
|
||||||
|
|
||||||
for message in messages or []:
|
for message in messages or []:
|
||||||
if not isinstance(message, dict):
|
if not isinstance(message, dict):
|
||||||
raise TypeError('messages must be a list of Message or dict-like objects')
|
raise TypeError('messages must be a list of Message or dict-like objects')
|
||||||
@@ -449,6 +452,8 @@ class AsyncClient(BaseClient):
|
|||||||
if not model:
|
if not model:
|
||||||
raise RequestError('must provide a model')
|
raise RequestError('must provide a model')
|
||||||
|
|
||||||
|
messages = deepcopy(messages)
|
||||||
|
|
||||||
for message in messages or []:
|
for message in messages or []:
|
||||||
if not isinstance(message, dict):
|
if not isinstance(message, dict):
|
||||||
raise TypeError('messages must be a list of strings')
|
raise TypeError('messages must be a list of strings')
|
||||||
|
|||||||
Reference in New Issue
Block a user