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 |
-
async def generate_image_response(message, image_data):
|
77 |
global conversation_history
|
|
|
78 |
user_mention = message.author.mention
|
79 |
|
80 |
system_message = f"""
|
@@ -85,7 +85,7 @@ async def generate_image_response(message, image_data):
|
|
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,8 +93,7 @@ async def generate_image_response(message, image_data):
|
|
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,8 +101,6 @@ async def generate_image_response(message, image_data):
|
|
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
|
@@ -126,7 +123,7 @@ async def generate_image_response(message, image_data):
|
|
126 |
temperature=0.7,
|
127 |
system=system_message,
|
128 |
messages=conversation_history,
|
129 |
-
|
130 |
)
|
131 |
|
132 |
full_response_text = response.content[0].text
|
@@ -156,7 +153,7 @@ async def generate_data_response(message, data, filename):
|
|
156 |
temperature=0.7,
|
157 |
system=system_message,
|
158 |
messages=conversation_history,
|
159 |
-
|
160 |
)
|
161 |
|
162 |
full_response_text = response.content[0].text
|
@@ -176,5 +173,4 @@ async def send_long_message(channel, message):
|
|
176 |
|
177 |
if __name__ == "__main__":
|
178 |
discord_client = MyClient(intents=intents)
|
179 |
-
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
180 |
-
|
|
|
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 |
{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 |
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 |
|
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
|
|
|
123 |
temperature=0.7,
|
124 |
system=system_message,
|
125 |
messages=conversation_history,
|
126 |
+
files=[("image.png", io.BytesIO(image_data))]
|
127 |
)
|
128 |
|
129 |
full_response_text = response.content[0].text
|
|
|
153 |
temperature=0.7,
|
154 |
system=system_message,
|
155 |
messages=conversation_history,
|
156 |
+
files=[("data.csv", io.BytesIO(data))]
|
157 |
)
|
158 |
|
159 |
full_response_text = response.content[0].text
|
|
|
173 |
|
174 |
if __name__ == "__main__":
|
175 |
discord_client = MyClient(intents=intents)
|
176 |
+
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
|