def submit():
record_timing() # Record time before submitting message
st.session_state.something = st.session_state.widget
st.session_state.widget = ''
if "messages" not in st.session_state:
st.session_state.messages = [{"role": "assistant", "content": "How may I help you today?"}]
if user_prompt := st.text_input("Your message here", on_change=submit, key="text_input"): # Assign unique key
st.session_state.messages.append({"role": "user", "content": user_prompt})
with st.chat_message("user"):
st.write(user_prompt)
if st.session_state.messages[-1]["role"] != "assistant":
with st.chat_message("assistant"):
with st.spinner("Thinking..."):
response = model(user_prompt, max_length, temp)
placeholder = st.empty()
full_response = ''
for item in response:
full_response += item
placeholder.markdown(full_response)
placeholder.markdown(full_response)
message = {"role": "assistant", "content": full_response}
st.session_state.messages.append(message)
вывод
я хочу, чтобы область вопросов пользователя сбрасывалась после отправки
Я используюstreamlit для создания приложения чата, и текстовый файл запроса не сохраняется при отправке. вот мой код и скриншот для того же самого [code]def submit(): record_timing() # Record time before submitting message st.session_state.something = st.session_state.widget st.session_state.widget = ''
if "messages" not in st.session_state: st.session_state.messages = [{"role": "assistant", "content": "How may I help you today?"}]
if user_prompt := st.text_input("Your message here", on_change=submit, key="text_input"): # Assign unique key st.session_state.messages.append({"role": "user", "content": user_prompt}) with st.chat_message("user"): st.write(user_prompt)
if st.session_state.messages[-1]["role"] != "assistant": with st.chat_message("assistant"): with st.spinner("Thinking..."): response = model(user_prompt, max_length, temp) placeholder = st.empty() full_response = '' for item in response: full_response += item placeholder.markdown(full_response) placeholder.markdown(full_response) message = {"role": "assistant", "content": full_response} st.session_state.messages.append(message) [/code] вывод я хочу, чтобы область вопросов пользователя сбрасывалась после отправки
OneDrive/Desktop/python prog/type.py/type1
Traceback (most recent call last):
File c:\Users\Sai Krishna\OneDrive\Desktop\python prog\type.py\type1 , line 1, in
p=int(input( enter 1st number: ))
ValueError: invalid literal for int() with base 10:...
Инструмент интерактивного чата QA-Pilot, который использует модели Ollama (или openAI) для быстрого понимания и навигации по репозиторию кода GitHub или сжатым файловым ресурсам.
Он использовал Python +streamlit + chromadb, при загрузке страницы он...
Я создал чат-бота черезstreamlit. Я использую просмотр прокрутки HTML для отображения моих изображений и использую JavaScript, чтобы иметь возможность отображать большое изображение, щелкая по нему, чтобы открыть всплывающее окно. Это мой код:
def...