Ali2206 commited on
Commit
b301866
·
verified ·
1 Parent(s): a1b649c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -10,7 +10,10 @@ from txagent import TxAgent
10
  from tooluniverse import ToolUniverse
11
 
12
  # Patch PyTorch to allow loading old numpy pickles
13
- torch.serialization.add_safe_globals([numpy.core.multiarray._reconstruct])
 
 
 
14
 
15
  logging.basicConfig(
16
  level=logging.INFO,
@@ -128,7 +131,12 @@ def respond(msg, chat_history, temperature, max_new_tokens, max_tokens, multi_ag
128
  )
129
  collected = ""
130
  for chunk in response_generator:
131
- collected += chunk.get("content", "") if isinstance(chunk, dict) else str(chunk)
 
 
 
 
 
132
  chat_history.append({"role": "assistant", "content": collected})
133
  except Exception as e:
134
  chat_history.append({"role": "assistant", "content": f"Error: {e}"})
@@ -159,4 +167,4 @@ def main():
159
  demo.launch(share=False)
160
 
161
  if __name__ == "__main__":
162
- main()
 
10
  from tooluniverse import ToolUniverse
11
 
12
  # Patch PyTorch to allow loading old numpy pickles
13
+ torch.serialization.add_safe_globals([
14
+ numpy.core.multiarray._reconstruct,
15
+ numpy.ndarray
16
+ ])
17
 
18
  logging.basicConfig(
19
  level=logging.INFO,
 
131
  )
132
  collected = ""
133
  for chunk in response_generator:
134
+ if chunk is None:
135
+ continue
136
+ elif isinstance(chunk, dict):
137
+ collected += chunk.get("content", "")
138
+ else:
139
+ collected += str(chunk)
140
  chat_history.append({"role": "assistant", "content": collected})
141
  except Exception as e:
142
  chat_history.append({"role": "assistant", "content": f"Error: {e}"})
 
167
  demo.launch(share=False)
168
 
169
  if __name__ == "__main__":
170
+ main()