返回提交历史
Modified
g4f/Provider/Glider.py
+2
-27
XFEstudio/gpt4free
Update g4f/Provider/Glider.py
eaf8619c
代码差异
1 个文件
+2
-27
@@ -20,12 +20,12 @@ class Glider(AsyncGeneratorProvider, ProviderModelMixin):
20
20
supports_message_history = True
21
21
22
22
default_model = 'chat-llama-3-1-70b'
23
reasoning_models = ['deepseek-ai/DeepSeek-R1']
24
23
models = [
25
24
'chat-llama-3-1-70b',
26
25
'chat-llama-3-1-8b',
27
26
'chat-llama-3-2-3b',
28
] + reasoning_models
27
'deepseek-ai/DeepSeek-R1'
28
]
29
29
30
30
model_aliases = {
31
31
"llama-3.1-70b": "chat-llama-3-1-70b",
@@ -69,9 +69,6 @@ class Glider(AsyncGeneratorProvider, ProviderModelMixin):
69
69
async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
70
70
await raise_for_status(response)
71
71
72
is_reasoning = False
73
current_reasoning = ""
74
75
72
async for chunk in response.content:
76
73
if not chunk:
77
74
continue
@@ -82,34 +79,12 @@ class Glider(AsyncGeneratorProvider, ProviderModelMixin):
82
79
continue
83
80
84
81
if "[DONE]" in text:
85
if is_reasoning and current_reasoning:
86
yield Reasoning(status=current_reasoning.strip())
87
82
yield FinishReason("stop")
88
83
return
89
84
90
85
try:
91
86
json_data = json.loads(text[6:])
92
87
content = json_data["choices"][0].get("delta", {}).get("content", "")
93
94
if model in cls.reasoning_models:
95
if "<think>" in content:
96
content = content.replace("<think>", "")
97
is_reasoning = True
98
current_reasoning = content
99
continue
100
101
if "</think>" in content:
102
content = content.replace("</think>", "")
103
is_reasoning = False
104
current_reasoning += content
105
yield Reasoning(status=current_reasoning.strip())
106
current_reasoning = ""
107
continue
108
109
if is_reasoning:
110
current_reasoning += content
111
continue
112
113
88
if content:
114
89
yield content
115
90