summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorggindinson <grisha.gindinson@gmail.com>2023-05-26 20:43:25 +0200
committerggindinson <grisha.gindinson@gmail.com>2023-05-26 20:43:25 +0200
commit97346e625709ff147a2c5a3884b0457aecd4a2e3 (patch)
treebdf2b0f32c8bfb4b16aab8b10fc2612872536e07
parentMerge pull request #607 from enganese/main (diff)
downloadgpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar.gz
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar.bz2
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar.lz
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar.xz
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.tar.zst
gpt4free-97346e625709ff147a2c5a3884b0457aecd4a2e3.zip
-rw-r--r--gpt4free/aicolors/__init__.py30
-rw-r--r--gpt4free/aicolors/typings/__init__.py9
2 files changed, 39 insertions, 0 deletions
diff --git a/gpt4free/aicolors/__init__.py b/gpt4free/aicolors/__init__.py
new file mode 100644
index 00000000..f3afa265
--- /dev/null
+++ b/gpt4free/aicolors/__init__.py
@@ -0,0 +1,30 @@
+import fake_useragent
+import requests
+import json
+from typings import AiColorsResponse
+
+
+class Completion:
+ @staticmethod
+ def create(
+ query: str = "",
+ ) -> AiColorsResponse:
+ headers = {
+ "authority": "jsuifmbqefnxytqwmaoy.functions.supabase.co",
+ "accept": "*/*",
+ "accept-language": "en-US,en;q=0.5",
+ "cache-control": "no-cache",
+ "sec-fetch-dest": "empty",
+ "sec-fetch-mode": "cors",
+ "sec-fetch-site": "same-origin",
+ "user-agent": fake_useragent.UserAgent().random,
+ }
+
+ json_data = {"query": query}
+
+ url = "https://jsuifmbqefnxytqwmaoy.functions.supabase.co/chatgpt"
+ request = requests.post(url, headers=headers, json=json_data, timeout=30)
+ data = request.json().get("text").get("content")
+ json_data = json.loads(data.replace("\n ", ""))
+
+ return AiColorsResponse(**json_data)
diff --git a/gpt4free/aicolors/typings/__init__.py b/gpt4free/aicolors/typings/__init__.py
new file mode 100644
index 00000000..8c4f29d1
--- /dev/null
+++ b/gpt4free/aicolors/typings/__init__.py
@@ -0,0 +1,9 @@
+from dataclasses import dataclass
+
+
+@dataclass
+class AiColorsResponse:
+ background: str
+ primary: str
+ accent: str
+ text: str