返回提交历史
Modified
g4f/Provider/Koala.py
+6
-5
XFEstudio/gpt4free
refactor(g4f/Provider/Koala.py): update URL structure and default model
b18156a2
代码差异
1 个文件
+6
-5
@@ -10,7 +10,8 @@ from .helper import get_random_string, get_connector
10
10
from ..requests import raise_for_status
11
11
12
12
class Koala(AsyncGeneratorProvider, ProviderModelMixin):
13
url = "https://koala.sh"
13
url = "https://koala.sh/chat"
14
api_endpoint = "https://koala.sh/api/gpt/"
14
15
working = True
15
16
supports_message_history = True
16
17
supports_gpt_4 = True
@@ -26,17 +27,17 @@ class Koala(AsyncGeneratorProvider, ProviderModelMixin):
26
27
**kwargs: Any
27
28
) -> AsyncGenerator[Dict[str, Union[str, int, float, List[Dict[str, Any]], None]], None]:
28
29
if not model:
29
model = "gpt-3.5-turbo"
30
model = "gpt-4o-mini"
30
31
31
32
headers = {
32
33
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0",
33
34
"Accept": "text/event-stream",
34
35
"Accept-Language": "de,en-US;q=0.7,en;q=0.3",
35
36
"Accept-Encoding": "gzip, deflate, br",
36
"Referer": f"{cls.url}/chat",
37
"Referer": f"{cls.url}",
37
38
"Flag-Real-Time-Data": "false",
38
39
"Visitor-ID": get_random_string(20),
39
"Origin": cls.url,
40
"Origin": "https://koala.sh",
40
41
"Alt-Used": "koala.sh",
41
42
"Sec-Fetch-Dest": "empty",
42
43
"Sec-Fetch-Mode": "cors",
@@ -67,7 +68,7 @@ class Koala(AsyncGeneratorProvider, ProviderModelMixin):
67
68
"model": model,
68
69
}
69
70
70
async with session.post(f"{cls.url}/api/gpt/", json=data, proxy=proxy) as response:
71
async with session.post(f"{cls.api_endpoint}", json=data, proxy=proxy) as response:
71
72
await raise_for_status(response)
72
73
async for chunk in cls._parse_event_stream(response):
73
74
yield chunk