diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-03-16 18:22:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 18:22:26 +0100 |
commit | fb2061da48525edab9cd993205bb5e30c386aa1a (patch) | |
tree | 1e740bd6955dfd27b9a4d773df07234ed9e5c75e /g4f/requests/curl_cffi.py | |
parent | Merge pull request #1694 from ComRSMaster/main (diff) | |
parent | Add conversation support for Bing (diff) | |
download | gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.gz gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.bz2 gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.lz gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.xz gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.tar.zst gpt4free-fb2061da48525edab9cd993205bb5e30c386aa1a.zip |
Diffstat (limited to 'g4f/requests/curl_cffi.py')
-rw-r--r-- | g4f/requests/curl_cffi.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/g4f/requests/curl_cffi.py b/g4f/requests/curl_cffi.py index cfcdd63b..91142365 100644 --- a/g4f/requests/curl_cffi.py +++ b/g4f/requests/curl_cffi.py @@ -1,6 +1,6 @@ from __future__ import annotations -from curl_cffi.requests import AsyncSession, Response +from curl_cffi.requests import AsyncSession, Response, CurlMime from typing import AsyncGenerator, Any from functools import partialmethod import json @@ -65,6 +65,8 @@ class StreamSession(AsyncSession): def request( self, method: str, url: str, **kwargs ) -> StreamResponse: + if isinstance(kwargs.get("data"), CurlMime): + kwargs["multipart"] = kwargs.pop("data") """Create and return a StreamResponse object for the given HTTP request.""" return StreamResponse(super().request(method, url, stream=True, **kwargs)) @@ -75,3 +77,7 @@ class StreamSession(AsyncSession): put = partialmethod(request, "PUT") patch = partialmethod(request, "PATCH") delete = partialmethod(request, "DELETE") + +class FormData(CurlMime): + def add_field(self, name, data=None, content_type: str = None, filename: str = None) -> None: + self.addpart(name, content_type=content_type, filename=filename, data=data)
\ No newline at end of file |