Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -8,7 +8,12 @@ from dotenv import load_dotenv
|
|
| 8 |
|
| 9 |
load_dotenv()
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
PROMPT_STYLE = get_prompt("PROMPT_STYLE")
|
| 14 |
PROMPT_TEXT = get_prompt("PROMPT_TEXT")
|
|
@@ -19,7 +24,7 @@ SYSPROMPT_TEXT = get_prompt("SYSPROMPT_TEXT")
|
|
| 19 |
def get_song_output(artist, song_text):
|
| 20 |
try:
|
| 21 |
# Get style music from artist
|
| 22 |
-
style_glm =
|
| 23 |
if style_glm:
|
| 24 |
style = style_glm
|
| 25 |
else:
|
|
@@ -29,7 +34,7 @@ def get_song_output(artist, song_text):
|
|
| 29 |
style = ''
|
| 30 |
|
| 31 |
try:
|
| 32 |
-
text_glm =
|
| 33 |
if text_glm:
|
| 34 |
text = text_glm
|
| 35 |
else:
|
|
@@ -101,7 +106,7 @@ with gr.Blocks() as demo:
|
|
| 101 |
fn=get_song_output,
|
| 102 |
inputs=[name_input, text_input],
|
| 103 |
outputs=[style_output, song_output]
|
| 104 |
-
)
|
| 105 |
|
| 106 |
demo.css = """
|
| 107 |
#header {
|
|
|
|
| 8 |
|
| 9 |
load_dotenv()
|
| 10 |
|
| 11 |
+
if os.getenv("OPENAI_API_KEY",False):
|
| 12 |
+
print ("using OPENAI_API_KEY")
|
| 13 |
+
run_llm=run_openai
|
| 14 |
+
else:
|
| 15 |
+
print ("using glm from huggingface")
|
| 16 |
+
run_llm=run_glm
|
| 17 |
|
| 18 |
PROMPT_STYLE = get_prompt("PROMPT_STYLE")
|
| 19 |
PROMPT_TEXT = get_prompt("PROMPT_TEXT")
|
|
|
|
| 24 |
def get_song_output(artist, song_text):
|
| 25 |
try:
|
| 26 |
# Get style music from artist
|
| 27 |
+
style_glm = run_llm(f"Describe {artist}", sys_prompt=SYSPROMPT_STYLE)
|
| 28 |
if style_glm:
|
| 29 |
style = style_glm
|
| 30 |
else:
|
|
|
|
| 34 |
style = ''
|
| 35 |
|
| 36 |
try:
|
| 37 |
+
text_glm = run_llm(f"{PROMPT_TEXT}\n{style}\n#Text song:\n{song_text}\n{PROMPT_TEXT2}", sys_prompt=SYSPROMPT_TEXT)
|
| 38 |
if text_glm:
|
| 39 |
text = text_glm
|
| 40 |
else:
|
|
|
|
| 106 |
fn=get_song_output,
|
| 107 |
inputs=[name_input, text_input],
|
| 108 |
outputs=[style_output, song_output]
|
| 109 |
+
)
|
| 110 |
|
| 111 |
demo.css = """
|
| 112 |
#header {
|