Merge pull request #158 from tillfalko/main

Avoid side effects if chat message contains images
This commit is contained in:
Michael Yang 2024-06-05 11:28:41 -07:00 committed by GitHub
commit 57c597b60e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import platform
import urllib.parse
from os import PathLike
from pathlib import Path
from copy import deepcopy
from hashlib import sha256
from base64 import b64encode, b64decode
@ -164,6 +165,8 @@ class Client(BaseClient):
if not model:
raise RequestError('must provide a model')
messages = deepcopy(messages)
for message in messages or []:
if not isinstance(message, dict):
raise TypeError('messages must be a list of Message or dict-like objects')
@ -449,6 +452,8 @@ class AsyncClient(BaseClient):
if not model:
raise RequestError('must provide a model')
messages = deepcopy(messages)
for message in messages or []:
if not isinstance(message, dict):
raise TypeError('messages must be a list of strings')