mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2024-12-25 04:44:50 +03:00
Update app.py
1. Improved error handling in send_msg to log specific exceptions. 2. Changed logging level to WARNING for better visibility. 3. Removed the list for port and used the port directly from the argument.
This commit is contained in:
parent
726cc339bc
commit
ca42998bbf
@ -9,14 +9,13 @@ app.logger.setLevel(logging.ERROR)
|
||||
log = logging.getLogger('werkzeug')
|
||||
log.setLevel(logging.ERROR)
|
||||
messages = []
|
||||
port = [8000]
|
||||
|
||||
def send_msg(role, text):
|
||||
try:
|
||||
data = {"role": role, "text": text}
|
||||
response = requests.post(f"http://127.0.0.1:{port[-1]}/send_message", json=data)
|
||||
except:
|
||||
logging.info("flask app.py did not start for online log")
|
||||
response = requests.post(f"http://127.0.0.1:{port}/send_message", json=data) # Updated to use port directly
|
||||
except Exception as e: # Improved error handling
|
||||
logging.error(f"Error sending message: {e}")
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@ -63,6 +62,6 @@ if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='argparse')
|
||||
parser.add_argument('--port', type=int, default=8000, help="port")
|
||||
args = parser.parse_args()
|
||||
port.append(args.port)
|
||||
print(f"Please visit http://127.0.0.1:{port[-1]}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).")
|
||||
app.run(host='0.0.0.0', debug=False, port=port[-1])
|
||||
port = args.port # Removed list and used port directly
|
||||
print(f"Please visit http://127.0.0.1:{port}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).")
|
||||
app.run(host='0.0.0.0', debug=False, port=port) # Updated to use port directly
|
||||
|
Loading…
Reference in New Issue
Block a user