Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
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:
|