Spaces:
Sleeping
Sleeping
Rob Learsch commited on
Commit ·
0cf4f3e
1
Parent(s): 9f3d759
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,9 +110,10 @@ def artist_response(gemma_response, artist):
|
|
| 110 |
|
| 111 |
return lyric_response
|
| 112 |
|
| 113 |
-
def chat_with_musician(user_input, history, artist
|
| 114 |
if history is None:
|
| 115 |
history = []
|
|
|
|
| 116 |
if artist != previous_artist:
|
| 117 |
# Reset history if the artist changes
|
| 118 |
history = []
|
|
@@ -138,7 +139,7 @@ def chat_with_musician(user_input, history, artist, previous_artist=None):
|
|
| 138 |
|
| 139 |
history.append({"role": "user", "content": user_input})
|
| 140 |
history.append({"role": "assistant", "content": lyric_response})
|
| 141 |
-
|
| 142 |
#if artist == "Google Gemma":
|
| 143 |
# lyric_response = gemma_response
|
| 144 |
return lyric_response
|
|
@@ -186,7 +187,7 @@ client = InferenceClient(#provider="hf-inference",
|
|
| 186 |
system_message = "Don't be too repetitive. Please limit your respone to only a few sentences."
|
| 187 |
#Function to generate chatbot responses
|
| 188 |
|
| 189 |
-
|
| 190 |
Artist_dropdown = gr.Dropdown(choices=["Radiohead", "Kendrick Lamar","Grateful Dead","Google Gemma"],
|
| 191 |
value="Radiohead",
|
| 192 |
label="Select artist",
|
|
|
|
| 110 |
|
| 111 |
return lyric_response
|
| 112 |
|
| 113 |
+
def chat_with_musician(user_input, history, artist):
|
| 114 |
if history is None:
|
| 115 |
history = []
|
| 116 |
+
previous_artist = artist_history[-1]
|
| 117 |
if artist != previous_artist:
|
| 118 |
# Reset history if the artist changes
|
| 119 |
history = []
|
|
|
|
| 139 |
|
| 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
|
|
|
|
| 187 |
system_message = "Don't be too repetitive. Please limit your respone to only a few sentences."
|
| 188 |
#Function to generate chatbot responses
|
| 189 |
|
| 190 |
+
artist_history = [""] # Variable to keep track of the previous artist
|
| 191 |
Artist_dropdown = gr.Dropdown(choices=["Radiohead", "Kendrick Lamar","Grateful Dead","Google Gemma"],
|
| 192 |
value="Radiohead",
|
| 193 |
label="Select artist",
|