Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
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":
|
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
|