ajayarora1235 commited on
Commit
3482c4c
1 Parent(s): f362ef8

get rid of finish full song button

Browse files
Files changed (3) hide show
  1. app.py +16 -16
  2. chat.py +29 -0
  3. suno.py +10 -10
app.py CHANGED
@@ -199,7 +199,7 @@ with gr.Blocks(css=css) as demo:
199
  return button_dict[button_name]
200
 
201
  def set_regenerate_query(textbox, current_section, current_lyrics, curr_tags, clip_to_continue):
202
- return f"Can you revise this section so it uses these lyrics and instrumentals and then generate an audio snippet using it?\nLyrics:\n{current_lyrics}Instrumental tags: {curr_tags}\nClip to continue: {clip_to_continue}"
203
  def set_snippet_query(textbox):
204
  return "Can I have an audio snippet of what we have now?"
205
  def set_finish_query(textbox):
@@ -247,26 +247,26 @@ with gr.Blocks(css=css) as demo:
247
  make_modal_visible, [tutorial_step], [tutorial_step, modal, modal_1, modal_2]
248
  )
249
 
250
- with gr.Row():
251
- # get_snippet_button = gr.Button("Get Audio Snippet", scale=2)
252
- done = gr.Button("Finish Full Song 🎶", scale=4)
253
- #autoGPT_checkbox = gr.Checkbox(label="AutoGPT", value=True, info="Auto-generate responses from journal entry", interactive=True, scale=2)
254
- #journal_llm_creativity = gr.Slider(label="Journal LLM Temperature", minimum=0, maximum=1, step=0.01, value=1, interactive=True, scale=2)
255
- reset_button = gr.Button("Reset", scale=2)
256
 
257
- def reset_chat(messages, chatbot_history):
258
- messages = messages[:2]
259
- chatbot_history = messages_to_history(messages[:2])
260
- return messages, chatbot_history, '', '', '', '', gr.HTML('<center>generating...</center>'), [], []
261
 
262
- reset_button.click(reset_chat, inputs=[messages, chatbot_history], outputs=[messages, chatbot_history, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options])
263
 
264
 
265
- done.click(set_finish_query, inputs=[textbox], outputs=[textbox]).then(model_chat,
266
- inputs=[genre_input, textbox, chatbot_history, messages, generated_audios],
267
- outputs=[textbox, chatbot_history, messages, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options])
268
 
269
- demo.load(reset_chat, inputs=[messages, chatbot_history], outputs=[messages, chatbot_history, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios])
270
 
271
 
272
  # with gr.Row():
 
199
  return button_dict[button_name]
200
 
201
  def set_regenerate_query(textbox, current_section, current_lyrics, curr_tags, clip_to_continue):
202
+ return f"Can you revise this section so it uses these lyrics and instrumentals and then generate an audio snippet using it?\nLyrics:\n{current_lyrics}Instrumental tags: {curr_tags}"
203
  def set_snippet_query(textbox):
204
  return "Can I have an audio snippet of what we have now?"
205
  def set_finish_query(textbox):
 
247
  make_modal_visible, [tutorial_step], [tutorial_step, modal, modal_1, modal_2]
248
  )
249
 
250
+ # with gr.Row():
251
+ # # get_snippet_button = gr.Button("Get Audio Snippet", scale=2)
252
+ # done = gr.Button("Finish Full Song 🎶", scale=4)
253
+ # #autoGPT_checkbox = gr.Checkbox(label="AutoGPT", value=True, info="Auto-generate responses from journal entry", interactive=True, scale=2)
254
+ # #journal_llm_creativity = gr.Slider(label="Journal LLM Temperature", minimum=0, maximum=1, step=0.01, value=1, interactive=True, scale=2)
255
+ # reset_button = gr.Button("Reset", scale=2)
256
 
257
+ # def reset_chat(messages, chatbot_history):
258
+ # messages = messages[:2]
259
+ # chatbot_history = messages_to_history(messages[:2])
260
+ # return messages, chatbot_history, '', '', '', '', gr.HTML('<center>generating...</center>'), [], []
261
 
262
+ # reset_button.click(reset_chat, inputs=[messages, chatbot_history], outputs=[messages, chatbot_history, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options])
263
 
264
 
265
+ # done.click(set_finish_query, inputs=[textbox], outputs=[textbox]).then(model_chat,
266
+ # inputs=[genre_input, textbox, chatbot_history, messages, generated_audios],
267
+ # outputs=[textbox, chatbot_history, messages, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options])
268
 
269
+ # demo.load(reset_chat, inputs=[messages, chatbot_history], outputs=[messages, chatbot_history, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios])
270
 
271
 
272
  # with gr.Row():
chat.py CHANGED
@@ -491,6 +491,35 @@ def model_chat(genre_input, query: Optional[str], history: Optional[History], me
491
  yield '', new_history, new_messages, snippet_lyrics.split("\n")[0], snippet_lyrics, snippet_instrumental_tags, clips_to_continue, None, generated_audios, buttons
492
 
493
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  print("MAKE SONG IS DONE")
495
  ## filter out suno link from tool query arg
496
  clip_id = song_link.split("https://audiopipe.suno.ai/?item_id=")[1]
 
491
  yield '', new_history, new_messages, snippet_lyrics.split("\n")[0], snippet_lyrics, snippet_instrumental_tags, clips_to_continue, None, generated_audios, buttons
492
 
493
  return
494
+
495
+
496
+ if "no clip with that ID" in song_link:
497
+ tool_message = {
498
+ 'role': 'tool',
499
+ 'tool_call_id': tool_call_id,
500
+ 'name': tool_function_name,
501
+ 'content': 'The clip ID was incorrect, maybe clarify with the user.'
502
+ }
503
+
504
+ new_messages = messages + [tool_message]
505
+
506
+ model_response_with_function_call = oai_client.chat.completions.create(
507
+ model="gpt-4o",
508
+ messages=new_messages,
509
+ ) # get a new response from the model where it can see the function response
510
+ current_response = model_response_with_function_call.choices[0].message.content
511
+
512
+ role = "assistant"
513
+ new_messages = new_messages + [{'role': role, 'content': current_response}]
514
+ new_history = messages_to_history(new_messages)
515
+
516
+ generated_audios = update_song_links(generated_audios)
517
+ clips_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=[x[3] for x in generated_audios]+[""], interactive=True)
518
+ buttons = []
519
+
520
+ yield '', new_history, new_messages, snippet_lyrics.split("\n")[0], snippet_lyrics, snippet_instrumental_tags, clips_to_continue, None, generated_audios, buttons
521
+
522
+ return
523
  print("MAKE SONG IS DONE")
524
  ## filter out suno link from tool query arg
525
  clip_id = song_link.split("https://audiopipe.suno.ai/?item_id=")[1]
suno.py CHANGED
@@ -67,28 +67,28 @@ def generate_song(tags, prompt, save_path, clip_id=None, continue_at=30):
67
  # Check if response_data is a list or a dictionary
68
  elif isinstance(response_data, list):
69
  if len(response_data) == 0 or "status" not in response_data[0]:
70
- print("Invalid response data, update later")
71
- time.sleep(2)
72
- continue
 
73
  status = response_data[0]["status"]
74
  elif isinstance(response_data, dict):
75
  if "status" not in response_data:
76
- print("Invalid response data, update later")
 
77
  time.sleep(2)
78
  continue
79
  status = response_data["status"]
80
  else:
81
- print("Unexpected response format, update later")
 
82
  time.sleep(2)
83
  continue
84
 
85
- if status == 'streaming':
86
  return "Snippet to extend is still streaming, please wait to request later."
87
- if status == 'complete':
88
- break
89
  else:
90
- time.sleep(8)
91
- continue
92
 
93
  response = requests.post(api_endpoint_submit, json=data) #,headers=headers)
94
  response_data = response.json()
 
67
  # Check if response_data is a list or a dictionary
68
  elif isinstance(response_data, list):
69
  if len(response_data) == 0 or "status" not in response_data[0]:
70
+ print("Invalid response data, no clip with that ID found")
71
+ return "no clip with that ID found to continue from"
72
+ # time.sleep(2)
73
+ # continue
74
  status = response_data[0]["status"]
75
  elif isinstance(response_data, dict):
76
  if "status" not in response_data:
77
+ print("Invalid response data, no clip with that ID found")
78
+ return "no clip with that ID found to continue from"
79
  time.sleep(2)
80
  continue
81
  status = response_data["status"]
82
  else:
83
+ print("Unexpected response format, no clip with that ID found")
84
+ return "no clip with that ID found to continue from"
85
  time.sleep(2)
86
  continue
87
 
88
+ if status != 'complete':
89
  return "Snippet to extend is still streaming, please wait to request later."
 
 
90
  else:
91
+ break
 
92
 
93
  response = requests.post(api_endpoint_submit, json=data) #,headers=headers)
94
  response_data = response.json()