summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxtekky <98614666+xtekky@users.noreply.github.com>2023-06-04 00:28:50 +0200
committerGitHub <noreply@github.com>2023-06-04 00:28:50 +0200
commit9430f20fcfe5e7636835340c5d35483dd2ad246f (patch)
treed9f2f34d8524a055b0344a9ad0392cf43f04b00c
parentMerge pull request #636 from ramonvc/main (diff)
parentUpdate __init__.py (diff)
downloadgpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar.gz
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar.bz2
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar.lz
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar.xz
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.tar.zst
gpt4free-9430f20fcfe5e7636835340c5d35483dd2ad246f.zip
-rw-r--r--gpt4free/aiassist/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/gpt4free/aiassist/__init__.py b/gpt4free/aiassist/__init__.py
index f54feaee..95a9f08b 100644
--- a/gpt4free/aiassist/__init__.py
+++ b/gpt4free/aiassist/__init__.py
@@ -1,5 +1,5 @@
+import urllib.request
import json
-import requests
class Completion:
@@ -20,16 +20,17 @@ class Completion:
}
url = "http://43.153.7.56:8080/api/chat-process"
- request = requests.post(url, json=json_data)
- request.encoding = request.apparent_encoding
- content = request.content
+ headers = {"Content-type": "application/json"}
- response = Completion.__load_json(content)
- return response
+ data = json.dumps(json_data).encode("utf-8")
+ req = urllib.request.Request(url, data=data, headers=headers)
+ response = urllib.request.urlopen(req)
+ content = response.read().decode()
+
+ return Completion.__load_json(content)
@classmethod
def __load_json(cls, content) -> dict:
- decode_content = str(content.decode("utf-8"))
- split = decode_content.rsplit("\n", 1)[1]
+ split = content.rsplit("\n", 1)[1]
to_json = json.loads(split)
return to_json