Rob Learsch commited on
Commit
f1253c3
·
1 Parent(s): 0cf4f3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -116,7 +116,7 @@ def chat_with_musician(user_input, history, artist):
116
  previous_artist = artist_history[-1]
117
  if artist != previous_artist:
118
  # Reset history if the artist changes
119
- history = []
120
  messages = []
121
 
122
  for dict in history[-5*2:]: # Keep only the last 5 exchanges, #I think this must be even to ensure that the last user message is included
@@ -140,6 +140,8 @@ def chat_with_musician(user_input, history, artist):
140
  history.append({"role": "user", "content": user_input})
141
  history.append({"role": "assistant", "content": lyric_response})
142
  artist_history.append(artist) # Store the previous artist for the next call
 
 
143
  #if artist == "Google Gemma":
144
  # lyric_response = gemma_response
145
  return lyric_response
 
116
  previous_artist = artist_history[-1]
117
  if artist != previous_artist:
118
  # Reset history if the artist changes
119
+ history.clear()
120
  messages = []
121
 
122
  for dict in history[-5*2:]: # Keep only the last 5 exchanges, #I think this must be even to ensure that the last user message is included
 
140
  history.append({"role": "user", "content": user_input})
141
  history.append({"role": "assistant", "content": lyric_response})
142
  artist_history.append(artist) # Store the previous artist for the next call
143
+ artist_history = artist_history[-10:] # Keep only last 10 entries
144
+
145
  #if artist == "Google Gemma":
146
  # lyric_response = gemma_response
147
  return lyric_response