seawolf2357 commited on
Commit
c4670be
β€’
1 Parent(s): 0940998

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -37,7 +37,7 @@ if SPECIFIC_CHANNEL_ID:
37
  SPECIFIC_CHANNEL_ID = int(SPECIFIC_CHANNEL_ID)
38
 
39
  # μ›Ήν›… URL μ„€μ •
40
- WEBHOOK_URL = os.getenv("WEBHOOK_URL")
41
 
42
  # 전솑 μ‹€νŒ¨ μ‹œ μž¬μ‹œλ„ 횟수
43
  MAX_RETRIES = 3
@@ -124,8 +124,12 @@ async def generate_reply(comment, transcript):
124
  prompt = f"{system_prompt}\nλŒ“κΈ€: {comment}\nλΉ„λ””μ˜€ μžλ§‰: {transcript}"
125
  response = hf_client.text_generation(prompt)
126
  if response:
127
- response_json = json.loads(response) # λ¬Έμžμ—΄μ„ JSON으둜 νŒŒμ‹±
128
- return response_json.get("generated_text", "").strip()
 
 
 
 
129
  except Exception as e:
130
  logging.error(f"Error generating reply: {e}")
131
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
 
37
  SPECIFIC_CHANNEL_ID = int(SPECIFIC_CHANNEL_ID)
38
 
39
  # μ›Ήν›… URL μ„€μ •
40
+ WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
41
 
42
  # 전솑 μ‹€νŒ¨ μ‹œ μž¬μ‹œλ„ 횟수
43
  MAX_RETRIES = 3
 
124
  prompt = f"{system_prompt}\nλŒ“κΈ€: {comment}\nλΉ„λ””μ˜€ μžλ§‰: {transcript}"
125
  response = hf_client.text_generation(prompt)
126
  if response:
127
+ try:
128
+ response_json = json.loads(response) # λ¬Έμžμ—΄μ„ JSON으둜 νŒŒμ‹±
129
+ return response_json.get("generated_text", "").strip()
130
+ except json.JSONDecodeError:
131
+ logging.error(f"Failed to decode JSON: {response}")
132
+ return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
133
  except Exception as e:
134
  logging.error(f"Error generating reply: {e}")
135
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."