summaryrefslogtreecommitdiffstats
path: root/g4f/requests/curl_cffi.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-03-16 18:22:26 +0100
committerGitHub <noreply@github.com>2024-03-16 18:22:26 +0100
commitfb2061da48525edab9cd993205bb5e30c386aa1a (patch)
tree1e740bd6955dfd27b9a4d773df07234ed9e5c75e /g4f/requests/curl_cffi.py
parentMerge pull request #1694 from ComRSMaster/main (diff)
parentAdd conversation support for Bing (diff)
downloadgpt4free-0.2.5.0.tar
gpt4free-0.2.5.0.tar.gz
gpt4free-0.2.5.0.tar.bz2
gpt4free-0.2.5.0.tar.lz
gpt4free-0.2.5.0.tar.xz
gpt4free-0.2.5.0.tar.zst
gpt4free-0.2.5.0.zip
Diffstat (limited to '')
-rw-r--r--g4f/requests/curl_cffi.py8
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