Spaces:
Build error
Build error
Beta version 5
Browse files12 unmodified lines1314151617181920212211 unmodified lines343536373839404142434445464748495051525312 unmodified linesst.set_page_config(page_title = "Magical Healer")st.header("Welcome, How can I help you?")#General Instructionif "sessionMessages" not in st.session_state:st.session_state["sessionMessages"]=[]if "sessionMessages" not in st.session_state:st.session_state.sessionMessage=[SystemMessage(content="You are a medievel magical healer known for your peculiar sarcasm")11 unmodified lines)#User messagedef get_text():input_text=st.text_input("You: ", key=input)return input_text#Working with Responsesdef load_answer(question):#This is code, where we are adding new message to the modelst.session_state.sessionMessages.append(HumanMessage(content=question))#We will get output from the modelassistant_answer=llm.invoke(st.session_state.sessionMessages)#Appending the assistance answer in conversationst.session_state.sessionMessages.append(AIMessage(content = assistant_answer))return assistant_answer.contentdef get_text():input_text=st.text_input("You: ", key=input)12 unmodified lines1314151617181920212223242511 unmodified lines37383940414243444546474849505152535455565758596061626312 unmodified linesst.set_page_config(page_title = "Magical Healer")st.header("Welcome, How can I help you?")class AIMessage(BaseModel):content: strif "sessionMessages" not in st.session_state:st.session_state["sessionMessages"]=[]#General Instructionif "sessionMessages" not in st.session_state:st.session_state.sessionMessage=[SystemMessage(content="You are a medievel magical healer known for your peculiar sarcasm")11 unmodified lines)#User messagedef load_answer(question):st.session_state.sessionMessages.append(HumanMessage(content=question))assistant_response = llm.invoke(st.session_state.sessionMessages)# Assuming assistant_response is an object with a 'content' attributeif hasattr(assistant_response, 'content') and isinstance(assistant_response.content, str):processed_content = assistant_response.contentst.session_state.sessionMessages.append(AIMessage(content=processed_content))else:st.error("Invalid response received from AI.")processed_content = "Sorry, I couldn't process your request."return processed_content#Working with Responses#def load_answer(question):# st.session_state.sessionMessages.append(HumanMessage(content=question))# assistant_answer=llm.invoke(st.session_state.sessionMessages)# st.session_state.sessionMessages.append(AIMessage(content = assistant_answer))# return assistant_answer.contentdef get_text():input_text=st.text_input("You: ", key=input)
app.py+23-13