seawolf2357 commited on
Commit
1d2d6cf
ยท
verified ยท
1 Parent(s): 50384f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -72,9 +72,9 @@ class MyClient(discord.Client):
72
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
73
  )
74
 
75
- async def generate_response(message):
 
76
  global conversation_history
77
- user_input = message.content
78
  user_mention = message.author.mention
79
 
80
  system_message = f"""
@@ -85,7 +85,7 @@ async def generate_response(message):
85
  {user_mention}, DISCORD์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค.
86
  """
87
 
88
- conversation_history.append({"role": "user", "content": user_input})
89
  logging.debug(f'Conversation history updated: {conversation_history}')
90
 
91
  response = claude_client.messages.create(
@@ -93,7 +93,8 @@ async def generate_response(message):
93
  max_tokens=1000,
94
  temperature=0.7,
95
  system=system_message,
96
- messages=conversation_history
 
97
  )
98
 
99
  full_response_text = response.content[0].text
@@ -101,6 +102,8 @@ async def generate_response(message):
101
 
102
  conversation_history.append({"role": "assistant", "content": full_response_text})
103
  return f"{user_mention}, {full_response_text}"
 
 
104
 
105
  async def generate_image_response(message, image_data):
106
  global conversation_history
 
72
  isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
73
  )
74
 
75
+
76
+ async def generate_image_response(message, image_data):
77
  global conversation_history
 
78
  user_mention = message.author.mention
79
 
80
  system_message = f"""
 
85
  {user_mention}, DISCORD์—์„œ ์‚ฌ์šฉ์ž๋“ค์˜ ์งˆ๋ฌธ์— ๋‹ตํ•˜๋Š” ์–ด์‹œ์Šคํ„ดํŠธ์ž…๋‹ˆ๋‹ค.
86
  """
87
 
88
+ conversation_history.append({"role": "user", "content": "์ด๋ฏธ์ง€๋ฅผ ๋ถ„์„ํ•ด ์ฃผ์„ธ์š”."})
89
  logging.debug(f'Conversation history updated: {conversation_history}')
90
 
91
  response = claude_client.messages.create(
 
93
  max_tokens=1000,
94
  temperature=0.7,
95
  system=system_message,
96
+ messages=conversation_history,
97
+ files=[("image.png", io.BytesIO(image_data))] # ์ˆ˜์ •
98
  )
99
 
100
  full_response_text = response.content[0].text
 
102
 
103
  conversation_history.append({"role": "assistant", "content": full_response_text})
104
  return f"{user_mention}, {full_response_text}"
105
+
106
+
107
 
108
  async def generate_image_response(message, image_data):
109
  global conversation_history