返回提交历史
Modified
g4f/Provider/GradientNetwork.py
+15
-23
XFEstudio/gpt4free
Fix response parsing: use type "reply" with data.content/reasoningContent, update models
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
098b2401
代码差异
1 个文件
+15
-23
@@ -11,7 +11,7 @@ from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
11
11
class GradientNetwork(AsyncGeneratorProvider, ProviderModelMixin):
12
12
"""
13
13
Provider for chat.gradient.network
14
Supports streaming text generation with various Qwen models.
14
Supports streaming text generation with Qwen and GPT OSS models.
15
15
"""
16
16
label = "Gradient Network"
17
17
url = "https://chat.gradient.network"
@@ -23,18 +23,15 @@ class GradientNetwork(AsyncGeneratorProvider, ProviderModelMixin):
23
23
supports_system_message = True
24
24
supports_message_history = True
25
25
26
default_model = "qwen3-235b"
26
default_model = "Qwen3 235B"
27
27
models = [
28
28
default_model,
29
"qwen3-32b",
30
"deepseek-r1-0528",
31
"deepseek-v3-0324",
32
"llama-4-maverick",
29
"GPT OSS 120B",
33
30
]
34
31
model_aliases = {
35
"qwen-3-235b": "qwen3-235b",
36
"deepseek-r1": "deepseek-r1-0528",
37
"deepseek-v3": "deepseek-v3-0324",
32
"qwen-3-235b": "Qwen3 235B",
33
"qwen3-235b": "Qwen3 235B",
34
"gpt-oss-120b": "GPT OSS 120B",
38
35
}
39
36
40
37
@classmethod
@@ -62,7 +59,7 @@ class GradientNetwork(AsyncGeneratorProvider, ProviderModelMixin):
62
59
63
60
Yields:
64
61
str: Content chunks from the response
65
Reasoning: Thinking content when enable_thinking is True
62
Reasoning: Reasoning content when enable_thinking is True
66
63
"""
67
64
model = cls.get_model(model)
68
65
@@ -101,21 +98,16 @@ class GradientNetwork(AsyncGeneratorProvider, ProviderModelMixin):
101
98
data = json.loads(line)
102
99
msg_type = data.get("type")
103
100
104
if msg_type == "text":
105
# Regular text content
106
content = data.get("data")
107
if content:
108
yield content
101
if msg_type == "reply":
102
# Response chunks with content or reasoningContent
103
reply_data = data.get("data", {})
104
content = reply_data.get("content")
105
reasoning_content = reply_data.get("reasoningContent")
109
106
110
elif msg_type == "thinking":
111
# Thinking/reasoning content
112
content = data.get("data")
107
if reasoning_content:
108
yield Reasoning(reasoning_content)
113
109
if content:
114
yield Reasoning(content)
115
116
elif msg_type == "done":
117
# Stream complete
118
break
110
yield content
119
111
120
112
elif msg_type in ("clusterInfo", "blockUpdate"):
121
113
# Skip GPU cluster visualization messages