nanova commited on
Commit
7fb0028
·
1 Parent(s): 91b3449
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -50,9 +50,6 @@ def respond(
50
  "max_tokens": 32768
51
  }
52
 
53
- # print(f"[INFO] process user msg...")
54
- # print(f"[INFO] userMsg: {message}")
55
-
56
  try:
57
  with requests.post(API_URL, headers=headers, json=data, stream=True) as r:
58
  if r.status_code == 200:
@@ -68,13 +65,18 @@ def respond(
68
  if 'content' in delta:
69
  content = delta['content']
70
  if content:
71
- content = content.replace('<', '&lt;').replace('>', '&gt;')
72
- content = content.replace('*', '\\*')
73
  current_response += content
74
- yield current_response
 
 
 
 
 
 
75
  except json.JSONDecodeError:
76
  continue
77
- # print(f"[INFO] final response: {current_response}")
78
  else:
79
  print(f"[ERROR] Bad status code: {r.status_code}, response: {r.text}")
80
  yield "Service temporarily unavailable"
 
50
  "max_tokens": 32768
51
  }
52
 
 
 
 
53
  try:
54
  with requests.post(API_URL, headers=headers, json=data, stream=True) as r:
55
  if r.status_code == 200:
 
65
  if 'content' in delta:
66
  content = delta['content']
67
  if content:
68
+ # content = content.replace('<', '&lt;').replace('>', '&gt;')
69
+ # content = content.replace('*', '\\*')
70
  current_response += content
71
+ # yield current_response
72
+ formatted_response = current_response
73
+ if '<think>' in formatted_response and '</think>' in formatted_response:
74
+ formatted_response = formatted_response.replace('<think>', '> ')
75
+ formatted_response = formatted_response.replace('</think>', '')
76
+ formatted_response = formatted_response.replace('\n', '\n> ')
77
+ yield formatted_response
78
  except json.JSONDecodeError:
79
  continue
 
80
  else:
81
  print(f"[ERROR] Bad status code: {r.status_code}, response: {r.text}")
82
  yield "Service temporarily unavailable"