From a77848429ea449650659ad6e9eaa348c6b25f001 Mon Sep 17 00:00:00 2001 From: Commenter123321 <36051603+Commenter123321@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:21:38 +0200 Subject: make user agent easily changeable in deepai --- g4f/Provider/DeepAi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'g4f') diff --git a/g4f/Provider/DeepAi.py b/g4f/Provider/DeepAi.py index 5998254a..2f7f15c4 100644 --- a/g4f/Provider/DeepAi.py +++ b/g4f/Provider/DeepAi.py @@ -22,9 +22,10 @@ class DeepAi(AsyncGeneratorProvider): proxy: str = None, **kwargs ) -> AsyncResult: + agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" token_js = """ -var agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' +var agent = '""" + agent + """' var a, b, c, d, e, h, f, l, g, k, m, n, r, x, C, E, N, F, T, O, P, w, D, G, Q, R, W, I, aa, fa, na, oa, ha, ba, X, ia, ja, ka, J, la, K, L, ca, S, U, M, ma, B, da, V, Y; h = Math.round(1E11 * Math.random()) + ""; f = function() { @@ -52,7 +53,7 @@ f = function() { api_key = js2py.eval_js(token_js) headers = { "api-key": api_key, - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36", + "User-Agent": agent, **kwargs.get("headers", {}) } async with ClientSession( -- cgit v1.2.3