KevinHuSh
commited on
Commit
·
12c8841
1
Parent(s):
c07cfc8
fix tk_count undefine issue (#996)
Browse files### What problem does this PR solve?
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- rag/llm/chat_model.py +3 -2
rag/llm/chat_model.py
CHANGED
@@ -206,6 +206,7 @@ class QWenChat(Base):
|
|
206 |
if system:
|
207 |
history.insert(0, {"role": "system", "content": system})
|
208 |
ans = ""
|
|
|
209 |
try:
|
210 |
response = Generation.call(
|
211 |
self.model_name,
|
@@ -214,7 +215,6 @@ class QWenChat(Base):
|
|
214 |
stream=True,
|
215 |
**gen_conf
|
216 |
)
|
217 |
-
tk_count = 0
|
218 |
for resp in response:
|
219 |
if resp.status_code == HTTPStatus.OK:
|
220 |
ans = resp.output.choices[0]['message']['content']
|
@@ -261,6 +261,7 @@ class ZhipuChat(Base):
|
|
261 |
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
262 |
if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"]
|
263 |
ans = ""
|
|
|
264 |
try:
|
265 |
response = self.client.chat.completions.create(
|
266 |
model=self.model_name,
|
@@ -268,7 +269,6 @@ class ZhipuChat(Base):
|
|
268 |
stream=True,
|
269 |
**gen_conf
|
270 |
)
|
271 |
-
tk_count = 0
|
272 |
for resp in response:
|
273 |
if not resp.choices[0].delta.content:continue
|
274 |
delta = resp.choices[0].delta.content
|
@@ -439,6 +439,7 @@ class VolcEngineChat(Base):
|
|
439 |
if system:
|
440 |
history.insert(0, {"role": "system", "content": system})
|
441 |
ans = ""
|
|
|
442 |
try:
|
443 |
req = {
|
444 |
"parameters": {
|
|
|
206 |
if system:
|
207 |
history.insert(0, {"role": "system", "content": system})
|
208 |
ans = ""
|
209 |
+
tk_count = 0
|
210 |
try:
|
211 |
response = Generation.call(
|
212 |
self.model_name,
|
|
|
215 |
stream=True,
|
216 |
**gen_conf
|
217 |
)
|
|
|
218 |
for resp in response:
|
219 |
if resp.status_code == HTTPStatus.OK:
|
220 |
ans = resp.output.choices[0]['message']['content']
|
|
|
261 |
if "presence_penalty" in gen_conf: del gen_conf["presence_penalty"]
|
262 |
if "frequency_penalty" in gen_conf: del gen_conf["frequency_penalty"]
|
263 |
ans = ""
|
264 |
+
tk_count = 0
|
265 |
try:
|
266 |
response = self.client.chat.completions.create(
|
267 |
model=self.model_name,
|
|
|
269 |
stream=True,
|
270 |
**gen_conf
|
271 |
)
|
|
|
272 |
for resp in response:
|
273 |
if not resp.choices[0].delta.content:continue
|
274 |
delta = resp.choices[0].delta.content
|
|
|
439 |
if system:
|
440 |
history.insert(0, {"role": "system", "content": system})
|
441 |
ans = ""
|
442 |
+
tk_count = 0
|
443 |
try:
|
444 |
req = {
|
445 |
"parameters": {
|