seawolf2357 commited on
Commit
44568a0
1 Parent(s): cde7a7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -3,6 +3,7 @@ import aiohttp
3
  import os
4
  import json
5
  from collections import deque
 
6
 
7
  TOKEN = os.getenv("HUGGINGFACE_API_TOKEN")
8
 
@@ -84,9 +85,13 @@ async def respond(
84
 
85
  async def chat(message, history, system_message, max_tokens, temperature, top_p):
86
  response = ""
87
- async for chunk in respond(message, history, system_message, max_tokens, temperature, top_p):
88
- response = chunk
89
- yield response
 
 
 
 
90
 
91
  theme = "Nymbo/Nymbo_Theme"
92
 
@@ -109,6 +114,5 @@ demo = gr.ChatInterface(
109
  )
110
 
111
  if __name__ == "__main__":
112
- import asyncio
113
  asyncio.run(test_api()) # Run API test
114
- demo.queue().launch(max_threads=20)
 
3
  import os
4
  import json
5
  from collections import deque
6
+ import asyncio
7
 
8
  TOKEN = os.getenv("HUGGINGFACE_API_TOKEN")
9
 
 
85
 
86
  async def chat(message, history, system_message, max_tokens, temperature, top_p):
87
  response = ""
88
+ try:
89
+ async for chunk in respond(message, history, system_message, max_tokens, temperature, top_p):
90
+ response = chunk
91
+ yield response
92
+ except Exception as e:
93
+ print(f"Chat function error: {str(e)}")
94
+ yield f"An error occurred in the chat function: {str(e)}"
95
 
96
  theme = "Nymbo/Nymbo_Theme"
97
 
 
114
  )
115
 
116
  if __name__ == "__main__":
 
117
  asyncio.run(test_api()) # Run API test
118
+ demo.queue().launch(max_threads=20, show_error=True)