seawolf2357 commited on
Commit
9941c9f
β€’
1 Parent(s): e1b4bc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import discord
2
  import logging
3
  import os
@@ -131,13 +132,14 @@ async def generate_reply(comment, transcript):
131
  prompt = f"{system_prompt}\nλŒ“κΈ€: {comment}\nλΉ„λ””μ˜€ μžλ§‰: {transcript}"
132
  response = hf_client.text_generation(prompt)
133
  if response:
134
- # JSON νŒŒμ‹± μ‹œλ„
135
  try:
 
136
  response_json = json.loads(response)
137
  return response_json.get("generated_text", "").strip()
138
  except json.JSONDecodeError:
 
139
  logging.error(f"Failed to decode JSON: {response}")
140
- return response # JSON νŒŒμ‹± μ‹€νŒ¨ μ‹œ 응닡 κ·ΈλŒ€λ‘œ λ°˜ν™˜
141
  except Exception as e:
142
  logging.error(f"Error generating reply: {e}")
143
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."
 
1
+
2
  import discord
3
  import logging
4
  import os
 
132
  prompt = f"{system_prompt}\nλŒ“κΈ€: {comment}\nλΉ„λ””μ˜€ μžλ§‰: {transcript}"
133
  response = hf_client.text_generation(prompt)
134
  if response:
 
135
  try:
136
+ # JSON νŒŒμ‹± μ‹œλ„
137
  response_json = json.loads(response)
138
  return response_json.get("generated_text", "").strip()
139
  except json.JSONDecodeError:
140
+ # JSON νŒŒμ‹± μ‹€νŒ¨ μ‹œ 둜그 남기고 응닡 κ·ΈλŒ€λ‘œ λ°˜ν™˜
141
  logging.error(f"Failed to decode JSON: {response}")
142
+ return response.strip()
143
  except Exception as e:
144
  logging.error(f"Error generating reply: {e}")
145
  return "닡변을 생성할 수 μ—†μŠ΅λ‹ˆλ‹€."