Spaces:
Runtime error
Runtime error
Update ui/components.py
Browse files- ui/components.py +22 -4
ui/components.py
CHANGED
|
@@ -22,6 +22,19 @@ except Exception as e:
|
|
| 22 |
client_available = False
|
| 23 |
print(f"β Warning: Failed to initialize OpenAI client: {e}")
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
TAG_DEFAULT = "funk, pop, soul, rock, melodic, guitar, drums, bass, keyboard, percussion, 105 BPM, energetic, upbeat, groovy, vibrant, dynamic, duet, male and female vocals"
|
| 26 |
LYRIC_DEFAULT = """[verse - male]
|
| 27 |
Neon lights they flicker bright
|
|
@@ -147,15 +160,18 @@ def generate_lyrics_with_ai(prompt: str, genre: str, song_style: str) -> str:
|
|
| 147 |
print(f"π Sending request to OpenAI...")
|
| 148 |
|
| 149 |
# [MODIFIED] openai.ChatCompletion μ¬μ©
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
| 152 |
messages=[
|
| 153 |
{"role": "system", "content": LYRIC_SYSTEM_PROMPT},
|
| 154 |
{"role": "user", "content": user_prompt}
|
| 155 |
],
|
| 156 |
temperature=0.8,
|
| 157 |
-
max_tokens=1000
|
| 158 |
)
|
|
|
|
| 159 |
|
| 160 |
generated_lyrics = response.choices[0].message.content
|
| 161 |
print(f"β
Generated lyrics successfully")
|
|
@@ -1066,8 +1082,10 @@ def create_main_demo_ui(
|
|
| 1066 |
if __name__ == "__main__":
|
| 1067 |
print("π ACE-Step PRO μμ μ€...")
|
| 1068 |
demo = create_main_demo_ui()
|
|
|
|
| 1069 |
demo.launch(
|
| 1070 |
server_name="0.0.0.0",
|
| 1071 |
server_port=7860,
|
| 1072 |
-
share=True
|
|
|
|
| 1073 |
)
|
|
|
|
| 22 |
client_available = False
|
| 23 |
print(f"β Warning: Failed to initialize OpenAI client: {e}")
|
| 24 |
|
| 25 |
+
# βββ openai μ΄κΈ°ν λΆλΆ λ°λ‘ μλμ μΆκ° βββ
|
| 26 |
+
from packaging import version
|
| 27 |
+
def _chat_completion(**kwargs):
|
| 28 |
+
"""SDK λ²μ μ λ§μΆ° ChatCompletion νΈμΆμ μΆμν"""
|
| 29 |
+
if version.parse(openai.__version__) >= version.parse("1.0.0"):
|
| 30 |
+
# v1 μ€νμΌ
|
| 31 |
+
return openai.chat.completions.create(**kwargs)
|
| 32 |
+
else:
|
| 33 |
+
# ꡬλ²μ μ€νμΌ
|
| 34 |
+
return openai.ChatCompletion.create(**kwargs)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
TAG_DEFAULT = "funk, pop, soul, rock, melodic, guitar, drums, bass, keyboard, percussion, 105 BPM, energetic, upbeat, groovy, vibrant, dynamic, duet, male and female vocals"
|
| 39 |
LYRIC_DEFAULT = """[verse - male]
|
| 40 |
Neon lights they flicker bright
|
|
|
|
| 160 |
print(f"π Sending request to OpenAI...")
|
| 161 |
|
| 162 |
# [MODIFIED] openai.ChatCompletion μ¬μ©
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
response = _chat_completion(
|
| 166 |
+
model="gpt-4.1-mini",
|
| 167 |
messages=[
|
| 168 |
{"role": "system", "content": LYRIC_SYSTEM_PROMPT},
|
| 169 |
{"role": "user", "content": user_prompt}
|
| 170 |
],
|
| 171 |
temperature=0.8,
|
| 172 |
+
max_tokens=1000,
|
| 173 |
)
|
| 174 |
+
|
| 175 |
|
| 176 |
generated_lyrics = response.choices[0].message.content
|
| 177 |
print(f"β
Generated lyrics successfully")
|
|
|
|
| 1082 |
if __name__ == "__main__":
|
| 1083 |
print("π ACE-Step PRO μμ μ€...")
|
| 1084 |
demo = create_main_demo_ui()
|
| 1085 |
+
|
| 1086 |
demo.launch(
|
| 1087 |
server_name="0.0.0.0",
|
| 1088 |
server_port=7860,
|
| 1089 |
+
share=True, # 곡μ λ§ν¬
|
| 1090 |
+
ssr_mode=False # β SSR λΉνμ±ν
|
| 1091 |
)
|