seawolf2357 commited on
Commit
ce5155e
·
verified ·
1 Parent(s): a8a69ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -77,6 +77,8 @@ class MyClient(discord.Client):
77
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
78
  )
79
 
 
 
80
  async def generate_response(message):
81
  global conversation_history
82
  user_input = message.content
@@ -91,14 +93,20 @@ async def generate_response(message):
91
  full_response_text = system_message + "\n\n" + answer
92
  max_length = 2000
93
  if len(full_response_text) > max_length:
 
94
  for i in range(0, len(full_response_text), max_length):
95
  part_response = full_response_text[i:i+max_length]
96
  await message.channel.send(part_response)
 
 
 
 
97
  else:
98
  await message.channel.send(full_response_text)
 
 
 
99
 
100
- logging.debug(f'Full model response sent: {full_response_text}')
101
- conversation_history.append({"role": "assistant", "content": full_response_text})
102
 
103
  def search_in_dataset(query, dataset):
104
  for record in dataset['train']:
 
77
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
78
  )
79
 
80
+
81
+
82
  async def generate_response(message):
83
  global conversation_history
84
  user_input = message.content
 
93
  full_response_text = system_message + "\n\n" + answer
94
  max_length = 2000
95
  if len(full_response_text) > max_length:
96
+ response_parts = []
97
  for i in range(0, len(full_response_text), max_length):
98
  part_response = full_response_text[i:i+max_length]
99
  await message.channel.send(part_response)
100
+ response_parts.append(part_response)
101
+ logging.debug(f'Full model response sent: {full_response_text}')
102
+ conversation_history.append({"role": "assistant", "content": full_response_text})
103
+ return "".join(response_parts) # 조각난 메시지들을 연결하여 반환
104
  else:
105
  await message.channel.send(full_response_text)
106
+ logging.debug(f'Full model response sent: {full_response_text}')
107
+ conversation_history.append({"role": "assistant", "content": full_response_text})
108
+ return full_response_text # 전체 메시지를 반환
109
 
 
 
110
 
111
  def search_in_dataset(query, dataset):
112
  for record in dataset['train']: