Spaces:
Sleeping
Sleeping
Update app.py
Browse files219 unmodified lines2202212222232242252262272283 unmodified lines232233234235236237238219 unmodified linesdef chat_fn(message, history, system_prompt, temperature):"""Main chat function"""if not chat_model.model_loaded:return "Please wait for the model to load or reload the space."# Convert history formatformatted_history = []for user_msg, assistant_msg in history:formatted_history.append({"role": "user", "content": user_msg})3 unmodified lines# Generate responseresponse = chat_model.generate_response(message, formatted_history, system_prompt, temperature)return responsedef chat_stream_fn(message, history, system_prompt, temperature):"""Streaming chat function"""219 unmodified lines2202212222232242252262272283 unmodified lines232233234235236237238239219 unmodified linesdef chat_fn(message, history, system_prompt, temperature):"""Main chat function"""if not chat_model.model_loaded:return history + [[message, "Please wait for the model to load or reload the space."]]# Convert history format for the modelformatted_history = []for user_msg, assistant_msg in history:formatted_history.append({"role": "user", "content": user_msg})3 unmodified lines# Generate responseresponse = chat_model.generate_response(message, formatted_history, system_prompt, temperature)# Return updated history with new message pairreturn history + [[message, response]]def chat_stream_fn(message, history, system_prompt, temperature):"""Streaming chat function"""
app.py+4-3