Spaces:
Sleeping
Sleeping
Update app.py
Browse files2 unmodified lines345678963 unmodified lines73747576777879808182838485868788899091922 unmodified linesfrom models import load_model# Load the model oncedemo = load_model()# Page configurationst.set_page_config(63 unmodified linestry:# Generate response using the modelwith st.spinner("Generating response..."):# Pass inputs as positional arguments to the Gradio modelresponse = demo(f"{system_message}\n\nUser: {prompt}\nAssistant:",max_length=max_tokens, # Gradio parametertemperature=temperature,top_p=top_p)# Display assistant responsewith st.chat_message("assistant"):st.markdown(response)# Add assistant response to chat historyst.session_state.messages.append({"role": "assistant", "content": response})except Exception as e:st.error(f"An error occurred: {str(e)}")2 unmodified lines345678963 unmodified lines737475767778798081828384858687888990919293949596972 unmodified linesfrom models import load_model# Load the model oncegenerator = load_model()# Page configurationst.set_page_config(63 unmodified linestry:# Generate response using the modelwith st.spinner("Generating response..."):full_prompt = f"{system_message}\n\nUser: {prompt}\nAssistant:"response = generator(full_prompt,max_length=max_tokens,temperature=temperature,top_p=top_p,do_sample=True,num_return_sequences=1)[0]['generated_text']# Extract only the assistant's responseassistant_response = response.split("Assistant:")[-1].strip()# Display assistant responsewith st.chat_message("assistant"):st.markdown(assistant_response)# Add assistant response to chat historyst.session_state.messages.append({"role": "assistant", "content": assistant_response})except Exception as e:st.error(f"An error occurred: {str(e)}")
app.py+15-10