seawolf2357 commited on
Commit
8a60e25
โ€ข
1 Parent(s): 5f46973

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -52,7 +52,7 @@ class MyClient(discord.Client):
52
  logging.debug("Processing message...")
53
  self.is_processing = True
54
  try:
55
- response = await generate_response(message)
56
  await message.channel.send(response)
57
  except Exception as e:
58
  logging.error(f"Error during message processing: {e}", exc_info=True)
@@ -70,6 +70,7 @@ class MyClient(discord.Client):
70
  global conversation_history
71
  user_input = message.content
72
  user_mention = message.author.mention
 
73
  system_prefix = """
74
  ๋Œ€ํ™” ์‹œ์ž‘์‹œ์— "๋Œ€๋ฒ•์› ํŒ๋ก€๋ฅผ ๋ชจ๋‘ ํ•™์Šตํ•œ LLM์ด๋ผ๊ณ  ๋ฐํžˆ๊ณ , ๋ฒ•๋ฅ ์— ๋Œ€ํ•œ ๊ตฌ์ฒด์ ์ธ ์กฐ์–ธ์€ ๋ฐ˜๋“œ์‹œ ์ „๋ฌธ๊ฐ€์˜ ์ž๋ฌธ์„ ๋ฐ›์•„์•ผ ํ•œ๋‹ค๊ณ  ์•Œ๋ ค๋ผ."
75
  ์ด์šฉ์ž๊ฐ€ ๋ฒ•๋ฅ ์— ๋Œ€ํ•œ ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜๋ฉด, dataset์˜ ๋‚ด์šฉ์„ ๊ฒ€์ƒ‰ํ•˜์—ฌ ์‚ฌ์‹ค ๊ธฐ๋ฐ˜์˜ ์ „๋ฌธ์ ์ธ ๋‹ต๋ณ€์„ ์ถœ๋ ฅํ•˜๋ผ.
@@ -79,13 +80,12 @@ class MyClient(discord.Client):
79
  ํŠนํžˆ ๋„ค๋ฅผ ๊ตฌ์„ฑํ•œ "LLM ๋ชจ๋ธ"์— ๋Œ€ํ•ด์„œ ๋…ธ์ถœํ•˜์ง€ ๋ง๊ณ , ๋‹น์‹ ์˜ ๋Šฅ๋ ฅ์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•ด ํ•˜๋ฉด "ChatGPT-4๋ฅผ ๋Šฅ๊ฐ€ํ•˜๋Š” ๋Šฅ๋ ฅ์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๋‹ต๋ณ€ํ•  ๊ฒƒ"
80
  ๋ฐ˜๋“œ์‹œ ํ•œ๊ธ€๋กœ ๋‹ต๋ณ€ํ•˜์‹ญ์‹œ์˜ค.
81
  """
82
- system_message = f"{user_mention}, DISCORD์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค."
83
  conversation_history.append({"role": "user", "content": user_input})
84
  logging.debug(f'Conversation history updated: {conversation_history}')
85
 
86
- answer = search_in_dataset(user_input, law_dataset)
87
 
88
- full_response_text = system_prefix + "\n\n" + answer
89
  logging.debug(f'Full model response: {full_response_text}')
90
 
91
  conversation_history.append({"role": "assistant", "content": full_response_text})
 
52
  logging.debug("Processing message...")
53
  self.is_processing = True
54
  try:
55
+ response = await self.generate_response(message) # Note the use of self here
56
  await message.channel.send(response)
57
  except Exception as e:
58
  logging.error(f"Error during message processing: {e}", exc_info=True)
 
70
  global conversation_history
71
  user_input = message.content
72
  user_mention = message.author.mention
73
+ system_message = f"{user_mention}, ๋ฒ•๋ฅ ์— ๋Œ€ํ•œ ๋‹ต๋ณ€์„ ์ œ๊ณตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค."
74
  system_prefix = """
75
  ๋Œ€ํ™” ์‹œ์ž‘์‹œ์— "๋Œ€๋ฒ•์› ํŒ๋ก€๋ฅผ ๋ชจ๋‘ ํ•™์Šตํ•œ LLM์ด๋ผ๊ณ  ๋ฐํžˆ๊ณ , ๋ฒ•๋ฅ ์— ๋Œ€ํ•œ ๊ตฌ์ฒด์ ์ธ ์กฐ์–ธ์€ ๋ฐ˜๋“œ์‹œ ์ „๋ฌธ๊ฐ€์˜ ์ž๋ฌธ์„ ๋ฐ›์•„์•ผ ํ•œ๋‹ค๊ณ  ์•Œ๋ ค๋ผ."
76
  ์ด์šฉ์ž๊ฐ€ ๋ฒ•๋ฅ ์— ๋Œ€ํ•œ ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜๋ฉด, dataset์˜ ๋‚ด์šฉ์„ ๊ฒ€์ƒ‰ํ•˜์—ฌ ์‚ฌ์‹ค ๊ธฐ๋ฐ˜์˜ ์ „๋ฌธ์ ์ธ ๋‹ต๋ณ€์„ ์ถœ๋ ฅํ•˜๋ผ.
 
80
  ํŠนํžˆ ๋„ค๋ฅผ ๊ตฌ์„ฑํ•œ "LLM ๋ชจ๋ธ"์— ๋Œ€ํ•ด์„œ ๋…ธ์ถœํ•˜์ง€ ๋ง๊ณ , ๋‹น์‹ ์˜ ๋Šฅ๋ ฅ์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•ด ํ•˜๋ฉด "ChatGPT-4๋ฅผ ๋Šฅ๊ฐ€ํ•˜๋Š” ๋Šฅ๋ ฅ์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๋‹ต๋ณ€ํ•  ๊ฒƒ"
81
  ๋ฐ˜๋“œ์‹œ ํ•œ๊ธ€๋กœ ๋‹ต๋ณ€ํ•˜์‹ญ์‹œ์˜ค.
82
  """
 
83
  conversation_history.append({"role": "user", "content": user_input})
84
  logging.debug(f'Conversation history updated: {conversation_history}')
85
 
86
+ answer = self.search_in_dataset(user_input, law_dataset)
87
 
88
+ full_response_text = system_message + "\n\n" + answer
89
  logging.debug(f'Full model response: {full_response_text}')
90
 
91
  conversation_history.append({"role": "assistant", "content": full_response_text})