mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-18 08:02:09 +03:00
Added support for AiColors
This commit is contained in:
parent
e35264d3db
commit
97346e6257
30
gpt4free/aicolors/__init__.py
Normal file
30
gpt4free/aicolors/__init__.py
Normal file
@ -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)
|
9
gpt4free/aicolors/typings/__init__.py
Normal file
9
gpt4free/aicolors/typings/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class AiColorsResponse:
|
||||
background: str
|
||||
primary: str
|
||||
accent: str
|
||||
text: str
|
Loading…
Reference in New Issue
Block a user