1
- from lagent .llms import GPTStyleAPI
1
+ from lagent .llms import GPTStyleAPI , GPTAPI
2
2
3
3
def chat_xinfrence ():
4
4
api_base = 'http://192.168.26.213:13000/v1/chat/completions' # oneapi
@@ -98,7 +98,8 @@ def chat_lmdeploy():
98
98
99
99
def chat_oneapi ():
100
100
api_base = 'http://192.168.26.213:13000/v1/chat/completions' # oneapi
101
- model_name = "deepseek-r1-14b"
101
+ # model_name = "deepseek-r1-14b"
102
+ model_name = "Baichuan2-Turbo"
102
103
gpttool = GPTStyleAPI (
103
104
model_type = model_name ,
104
105
api_base = api_base ,
@@ -120,6 +121,30 @@ def chat_oneapi():
120
121
}])
121
122
print (res )
122
123
124
+ def chat_siliconflow ():
125
+ api_base = 'https://api.siliconflow.cn/v1/chat/completions' # oneapi
126
+ # model_name = "deepseek-r1-14b"
127
+ model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
128
+ gpttool = GPTStyleAPI (
129
+ model_type = model_name ,
130
+ api_base = api_base ,
131
+ key = "sk-srirwcmjqmbmyttandxidrtmlfqpxcigyacoabutufvdkkgl" ,
132
+ retry = 3 ,
133
+ meta_template = None ,
134
+ max_new_tokens = 512 ,
135
+ top_p = 0.8 ,
136
+ top_k = 40 ,
137
+ temperature = 0.8 ,
138
+ repetition_penalty = 1 ,
139
+ stream = False ,
140
+ stop_words = None ,
141
+ )
142
+ res = gpttool .chat (inputs = [
143
+ {
144
+ "role" : "user" ,
145
+ "content" : "世界第一高峰是"
146
+ }])
147
+ print (res )
123
148
def stream_chat_ollama ():
124
149
api_base = 'http://192.168.26.212:11434/api/chat' # ollama
125
150
model_name = "qwen:7b"
@@ -134,7 +159,6 @@ def stream_chat_ollama():
134
159
top_k = 40 ,
135
160
temperature = 0.8 ,
136
161
repetition_penalty = 1 ,
137
- stream = False ,
138
162
stop_words = None ,
139
163
)
140
164
res = gpttool .stream_chat (inputs = [
@@ -147,7 +171,9 @@ def stream_chat_ollama():
147
171
148
172
def stream_chat_oneapi ():
149
173
api_base = 'http://192.168.26.213:13000/v1/chat/completions' # oneapi
150
- model_name = "deepseek-r1-14b"
174
+ # model_name = "deepseek-r1-14b"
175
+ model_name = "Baichuan2-Turbo"
176
+ # model_name = "qwen:7b"
151
177
gpttool = GPTStyleAPI (
152
178
model_type = model_name ,
153
179
api_base = api_base ,
@@ -159,7 +185,31 @@ def stream_chat_oneapi():
159
185
top_k = 40 ,
160
186
temperature = 0.8 ,
161
187
repetition_penalty = 1 ,
162
- stream = False ,
188
+ stop_words = None ,
189
+ )
190
+ res = gpttool .stream_chat (inputs = [
191
+ {
192
+ "role" : "user" ,
193
+ "content" : "世界第一高峰是"
194
+ }])
195
+ for status , content , _ in res :
196
+ print (content , end = '' , flush = True )
197
+
198
+ def stream_chat_siliconflow ():
199
+ api_base = 'https://api.siliconflow.cn/v1/chat/completions' # oneapi
200
+ # model_name = "deepseek-r1-14b"
201
+ model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
202
+ gpttool = GPTStyleAPI (
203
+ model_type = model_name ,
204
+ api_base = api_base ,
205
+ key = "sk-srirwcmjqmbmyttandxidrtmlfqpxcigyacoabutufvdkkgl" ,
206
+ retry = 3 ,
207
+ meta_template = None ,
208
+ max_new_tokens = 512 ,
209
+ top_p = 0.8 ,
210
+ top_k = 40 ,
211
+ temperature = 0.8 ,
212
+ repetition_penalty = 1 ,
163
213
stop_words = None ,
164
214
)
165
215
res = gpttool .stream_chat (inputs = [
@@ -175,8 +225,10 @@ def stream_chat_oneapi():
175
225
# chat_direct()
176
226
# chat_ollama()
177
227
# chat_oneapi()
178
- chat_lmdeploy ()
228
+ # chat_lmdeploy()
229
+ # chat_siliconflow()
179
230
180
231
# #流式输出测试
181
232
# stream_chat_ollama()
182
- # stream_chat_oneapi()
233
+ # stream_chat_oneapi()
234
+ stream_chat_siliconflow ()
0 commit comments