ginipick commited on
Commit
d9ef286
Β·
verified Β·
1 Parent(s): 24c6882

Update ui/components.py

Browse files
Files changed (1) hide show
  1. 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
- response = openai.ChatCompletion.create(
151
- model="gpt-4o-mini",
 
 
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
  )