summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/AItianhuSpace.py
diff options
context:
space:
mode:
authorabc <98614666+xtekky@users.noreply.github.com>2023-10-21 01:52:19 +0200
committerabc <98614666+xtekky@users.noreply.github.com>2023-10-21 01:52:19 +0200
commitae8dae82cffb07eeeecc5b07ffc9b502e92bfe62 (patch)
tree6b24ca9b43ad4ace9347dbce2a66c000b9e12e28 /g4f/Provider/AItianhuSpace.py
parent~ | g4f v-0.1.7.0 (diff)
downloadgpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar.gz
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar.bz2
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar.lz
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar.xz
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.tar.zst
gpt4free-ae8dae82cffb07eeeecc5b07ffc9b502e92bfe62.zip
Diffstat (limited to 'g4f/Provider/AItianhuSpace.py')
-rw-r--r--g4f/Provider/AItianhuSpace.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/g4f/Provider/AItianhuSpace.py b/g4f/Provider/AItianhuSpace.py
index 7811c9c8..51297bcd 100644
--- a/g4f/Provider/AItianhuSpace.py
+++ b/g4f/Provider/AItianhuSpace.py
@@ -1,9 +1,9 @@
from __future__ import annotations
import random, json
-
-from ..typing import AsyncResult, Messages
-from ..requests import StreamSession
+from ..debug import logging
+from ..typing import AsyncResult, Messages
+from ..requests import StreamSession
from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
domains = {
@@ -17,37 +17,37 @@ class AItianhuSpace(AsyncGeneratorProvider):
supports_gpt_35_turbo = True
@classmethod
- async def create_async_generator(
- cls,
- model: str,
- messages: Messages,
- proxy: str = None,
- domain: str = None,
- cookies: dict = None,
- timeout: int = 120,
- **kwargs
- ) -> AsyncResult:
+ async def create_async_generator(cls,
+ model: str,
+ messages: Messages,
+ proxy: str = None,
+ domain: str = None,
+ cookies: dict = None,
+ timeout: int = 10, **kwargs) -> AsyncResult:
+
if not model:
model = "gpt-3.5-turbo"
+
elif not model in domains:
raise ValueError(f"Model are not supported: {model}")
+
if not domain:
chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
rand = ''.join(random.choice(chars) for _ in range(6))
domain = f"{rand}.{domains[model]}"
+
+ if logging:
+ print(f"AItianhuSpace | using domain: {domain}")
+
if not cookies:
- cookies = get_cookies(domain)
+ cookies = get_cookies('.aitianhu.space')
if not cookies:
- raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
+ raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://{domain} on chrome]")
url = f'https://{domain}'
- async with StreamSession(
- proxies={"https": proxy},
- cookies=cookies,
- timeout=timeout,
- impersonate="chrome110",
- verify=False
- ) as session:
+ async with StreamSession(proxies={"https": proxy},
+ cookies=cookies, timeout=timeout, impersonate="chrome110", verify=False) as session:
+
data = {
"prompt": format_prompt(messages),
"options": {},