返回提交历史
Added
g4f/Provider/AiMathGPT.py
+78
-0
Modified
g4f/Provider/__init__.py
+1
-0
Modified
g4f/models.py
+2
-1
XFEstudio/gpt4free
Added new provider (g4f/Provider/AiMathGPT.py)
9f394f96
代码差异
3 个文件
+81
-1
@@ -0,0 +1,78 @@
1
from __future__ import annotations
2
3
from aiohttp import ClientSession
4
5
from ..typing import AsyncResult, Messages
6
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
7
from .helper import format_prompt
8
9
class AiMathGPT(AsyncGeneratorProvider, ProviderModelMixin):
10
url = "https://aimathgpt.forit.ai"
11
api_endpoint = "https://aimathgpt.forit.ai/api/ai"
12
working = True
13
supports_stream = False
14
supports_system_message = True
15
supports_message_history = True
16
17
default_model = 'llama3'
18
models = ['llama3']
19
20
model_aliases = {"llama-3.1-70b": "llama3",}
21
22
@classmethod
23
def get_model(cls, model: str) -> str:
24
if model in cls.models:
25
return model
26
elif model in cls.model_aliases:
27
return cls.model_aliases[model]
28
else:
29
return cls.default_model
30
31
@classmethod
32
async def create_async_generator(
33
cls,
34
model: str,
35
messages: Messages,
36
proxy: str = None,
37
**kwargs
38
) -> AsyncResult:
39
model = cls.get_model(model)
40
41
headers = {
42
'accept': '*/*',
43
'accept-language': 'en-US,en;q=0.9',
44
'cache-control': 'no-cache',
45
'content-type': 'application/json',
46
'origin': cls.url,
47
'pragma': 'no-cache',
48
'priority': 'u=1, i',
49
'referer': f'{cls.url}/',
50
'sec-ch-ua': '"Chromium";v="129", "Not=A?Brand";v="8"',
51
'sec-ch-ua-mobile': '?0',
52
'sec-ch-ua-platform': '"Linux"',
53
'sec-fetch-dest': 'empty',
54
'sec-fetch-mode': 'cors',
55
'sec-fetch-site': 'same-origin',
56
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
57
}
58
59
async with ClientSession(headers=headers) as session:
60
data = {
61
"messages": [
62
{
63
"role": "system",
64
"content": ""
65
},
66
{
67
"role": "user",
68
"content": format_prompt(messages)
69
}
70
],
71
"model": model
72
}
73
74
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
75
response.raise_for_status()
76
response_data = await response.json()
77
filtered_response = response_data['result']['response']
78
yield filtered_response
@@ -18,6 +18,7 @@ from .Allyfy import Allyfy
18
18
from .AmigoChat import AmigoChat
19
19
from .AiChatOnline import AiChatOnline
20
20
from .AiChats import AiChats
21
from .AiMathGPT import AiMathGPT
21
22
from .Airforce import Airforce
22
23
from .Aura import Aura
23
24
from .Bing import Bing
@@ -6,6 +6,7 @@ from dataclasses import dataclass
6
6
from .Provider import IterListProvider, ProviderType
7
7
from .Provider import (
8
8
AIChatFree,
9
AiMathGPT,
9
10
Airforce,
10
11
Allyfy,
11
12
AmigoChat,
@@ -213,7 +214,7 @@ llama_3_1_8b = Model(
213
214
llama_3_1_70b = Model(
214
215
name = "llama-3.1-70b",
215
216
base_provider = "Meta Llama",
216
best_provider = IterListProvider([DDG, HuggingChat, Blackbox, FreeGpt, TeachAnything, Free2GPT, DeepInfraChat, DarkAI, Airforce, HuggingFace, PerplexityLabs])
217
best_provider = IterListProvider([DDG, HuggingChat, Blackbox, FreeGpt, TeachAnything, Free2GPT, DeepInfraChat, DarkAI, Airforce, AiMathGPT, HuggingFace, PerplexityLabs])
217
218
)
218
219
219
220
llama_3_1_405b = Model(