seawolf2357 commited on
Commit
c824b11
Β·
verified Β·
1 Parent(s): 0b58bb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -152,19 +152,23 @@ async def generate_replies(comments, transcript):
152
  {"role": "system", "content": f"λΉ„λ””μ˜€ μžλ§‰: {transcript}"},
153
  {"role": "user", "content": comment}
154
  ]
155
- loop = asyncio.get_event_loop()
156
- response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(
157
- messages, max_tokens=250, temperature=0.7, top_p=0.85))
158
-
159
- if response.choices and response.choices[0].message:
160
- reply = response.choices[0].message['content'].strip()
161
- else:
162
- reply = "닡글을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
 
 
 
163
  replies.append(reply)
164
 
165
  logging.debug(f'μƒμ„±λœ λ‹΅κΈ€: {replies}')
166
  return replies
167
 
 
168
  async def send_webhook_data(session, chunk_data, chunk_number):
169
  for attempt in range(MAX_RETRIES):
170
  try:
 
152
  {"role": "system", "content": f"λΉ„λ””μ˜€ μžλ§‰: {transcript}"},
153
  {"role": "user", "content": comment}
154
  ]
155
+ try:
156
+ loop = asyncio.get_event_loop()
157
+ response = await loop.run_in_executor(None, lambda: hf_client.chat_completion(
158
+ messages, max_tokens=250, temperature=0.7, top_p=0.85))
159
+ if response.choices and response.choices[0].message:
160
+ reply = response.choices[0].message['content'].strip()
161
+ else:
162
+ reply = "닡글을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
163
+ except Exception as e:
164
+ logging.error(f"API 호좜 쀑 였λ₯˜ λ°œμƒ: {e}")
165
+ reply = "μ„œλ²„ 였λ₯˜λ‘œ 인해 닡글을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
166
  replies.append(reply)
167
 
168
  logging.debug(f'μƒμ„±λœ λ‹΅κΈ€: {replies}')
169
  return replies
170
 
171
+
172
  async def send_webhook_data(session, chunk_data, chunk_number):
173
  for attempt in range(MAX_RETRIES):
174
  try: