Skip to content

Commit

Permalink
Update memorybot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-usa authored May 26, 2023
1 parent 68d2ff9 commit 01a5c26
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions memorybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def new_chat():
# MODEL = st.selectbox(label='Model', options=['gpt-3.5-turbo','text-davinci-003','text-davinci-002','code-davinci-002'])
# K = st.number_input(' (#)Summary of prompts to consider',min_value=3,max_value=1000)

@st.cache(allow_output_mutation=True)
def get_word_count():
return 0

def count_words(string):
words = string.split()
return len(words)
Expand Down Expand Up @@ -152,16 +156,15 @@ def count_words(string):
# Add a button to start a new chat
#st.sidebar.button("New Chat", on_click = new_chat, type='primary')

word_count = get_word_count()
# Get the user input
user_input = get_text()

# Generate the output using the ConversationChain object and the user input, and add the input/output to the session
if user_input:
output = Conversation.run(input=user_input)
st.session_state.past.append(user_input)
word_count += count_words(user_input)
st.session_state.generated.append(output)
word_count += count_words(output)

# Allow to download as well
download_str = []
Expand All @@ -175,6 +178,7 @@ def count_words(string):

# Can throw error - requires fix
download_str = '\n'.join(download_str)
word_count += count_words(download_str)

if download_str:
st.download_button('Download 下载',download_str)
Expand Down

0 comments on commit 01a5c26

Please sign in to comment.