summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorezerinz <edwinnnzx@gmail.com>2023-05-20 15:45:05 +0200
committerezerinz <edwinnnzx@gmail.com>2023-05-20 15:45:05 +0200
commit8449728aa3fed6c91d0aac371145f83b90295bb2 (patch)
tree415e0425dbb920bb023ba10ae91020f6e1354ac8
parentadd aiassist.site test (diff)
downloadgpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar.gz
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar.bz2
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar.lz
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar.xz
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.tar.zst
gpt4free-8449728aa3fed6c91d0aac371145f83b90295bb2.zip
Diffstat (limited to '')
-rw-r--r--gpt4free/aiassist/README.md19
-rw-r--r--gpt4free/aiassist/__init__.py34
2 files changed, 53 insertions, 0 deletions
diff --git a/gpt4free/aiassist/README.md b/gpt4free/aiassist/README.md
new file mode 100644
index 00000000..02904865
--- /dev/null
+++ b/gpt4free/aiassist/README.md
@@ -0,0 +1,19 @@
+aiassist.site
+
+### Example: `aiassist` <a name="example-assist></a>
+
+```python
+import aiassist
+
+question1 = "Who won the world series in 2020?"
+req = aiassist.Completion.create(prompt=question1)
+answer = req["text"]
+message_id = req["parentMessageId"]
+
+question2 = "Where was it played?"
+req2 = aiassist.Completion.create(prompt=question2, parentMessageId=message_id)
+answer2 = req2["text"]
+
+print(answer)
+print(answer2)
+```
diff --git a/gpt4free/aiassist/__init__.py b/gpt4free/aiassist/__init__.py
new file mode 100644
index 00000000..10082c22
--- /dev/null
+++ b/gpt4free/aiassist/__init__.py
@@ -0,0 +1,34 @@
+import json
+import requests
+
+
+class Completion:
+ @staticmethod
+ def create(
+ systemMessage: str = "You are a helpful assistant",
+ prompt: str = "",
+ parentMessageId: str = "",
+ temperature: float = 0.8,
+ top_p: float = 1,
+ ):
+ json_data = {
+ "prompt": prompt,
+ "options": {"parentMessageId": parentMessageId},
+ "systemMessage": systemMessage,
+ "temperature": temperature,
+ "top_p": top_p,
+ }
+
+ url = "http://43.153.7.56:8080/api/chat-process"
+ request = requests.post(url, json=json_data)
+ content = request.content
+
+ response = Completion.__load_json(content)
+ return response
+
+ @classmethod
+ def __load_json(cls, content) -> dict:
+ decode_content = str(content.decode("utf-8"))
+ split = decode_content.rsplit("\n", 1)[1]
+ to_json = json.loads(split)
+ return to_json