Spaces:
Sleeping
Sleeping
Rob Learsch commited on
Commit ·
f817407
1
Parent(s): c6204c3
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,21 +137,22 @@ def chat_with_musician(user_input, history, artist):
|
|
| 137 |
return f"Error: {str(e)}"
|
| 138 |
|
| 139 |
lyric_response = artist_response(gemma_response, artist)
|
| 140 |
-
if
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
| 155 |
|
| 156 |
history.append({"role": "user", "content": user_input})
|
| 157 |
history.append({"role": "assistant", "content": lyric_response})
|
|
|
|
| 137 |
return f"Error: {str(e)}"
|
| 138 |
|
| 139 |
lyric_response = artist_response(gemma_response, artist)
|
| 140 |
+
if len(messages)>1:
|
| 141 |
+
if lyric_response == messages[-2]["content"]:
|
| 142 |
+
# If the response is the same as the last one, get a new one:
|
| 143 |
+
messages[-1]={"role": "user", "content": system_message_repeated + "\n\n" + user_input}
|
| 144 |
+
try:
|
| 145 |
+
response = client.chat_completion(
|
| 146 |
+
messages=messages,
|
| 147 |
+
model="google/gemma-2-2b-it",
|
| 148 |
+
max_tokens=256,
|
| 149 |
+
temperature=0.75,
|
| 150 |
+
#top_p=0.9
|
| 151 |
+
)
|
| 152 |
+
gemma_response= response["choices"][0]["message"]["content"]
|
| 153 |
+
except Exception as e:
|
| 154 |
+
return f"Error: {str(e)}"
|
| 155 |
+
lyric_response = artist_response(gemma_response, artist)
|
| 156 |
|
| 157 |
history.append({"role": "user", "content": user_input})
|
| 158 |
history.append({"role": "assistant", "content": lyric_response})
|