Skip to content

Commit 5ad21d2

Browse files
authored
Merge branch 'dev' into abhimanyuyadav/add-extra-info-in-custom-node-in-new-builder
2 parents 2c191cc + 9bc9b53 commit 5ad21d2

File tree

4 files changed

+78
-24
lines changed

4 files changed

+78
-24
lines changed

autogpt_platform/backend/backend/blocks/discord/bot_blocks.py

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ class Input(BlockSchema):
171171
description="The content of the message to send"
172172
)
173173
channel_name: str = SchemaField(
174-
description="The name of the channel the message will be sent to"
174+
description="Channel ID or channel name to send the message to"
175175
)
176176
server_name: str = SchemaField(
177-
description="The name of the server where the channel is located",
178-
advanced=True, # Optional field for server name
177+
description="Server name (only needed if using channel name)",
178+
advanced=True,
179179
default="",
180180
)
181181

@@ -231,25 +231,49 @@ async def send_message(
231231
@client.event
232232
async def on_ready():
233233
print(f"Logged in as {client.user}")
234-
for guild in client.guilds:
235-
if server_name and guild.name != server_name:
236-
continue
237-
for channel in guild.text_channels:
238-
if channel.name == channel_name:
239-
# Split message into chunks if it exceeds 2000 characters
240-
chunks = self.chunk_message(message_content)
241-
last_message = None
242-
for chunk in chunks:
243-
last_message = await channel.send(chunk)
244-
result["status"] = "Message sent"
245-
result["message_id"] = (
246-
str(last_message.id) if last_message else ""
247-
)
248-
result["channel_id"] = str(channel.id)
249-
await client.close()
250-
return
251-
252-
result["status"] = "Channel not found"
234+
channel = None
235+
236+
# Try to parse as channel ID first
237+
try:
238+
channel_id = int(channel_name)
239+
channel = client.get_channel(channel_id)
240+
except ValueError:
241+
# Not a valid ID, will try name lookup
242+
pass
243+
244+
# If not found by ID (or not an ID), try name lookup
245+
if not channel:
246+
for guild in client.guilds:
247+
if server_name and guild.name != server_name:
248+
continue
249+
for ch in guild.text_channels:
250+
if ch.name == channel_name:
251+
channel = ch
252+
break
253+
if channel:
254+
break
255+
256+
if not channel:
257+
result["status"] = f"Channel not found: {channel_name}"
258+
await client.close()
259+
return
260+
261+
# Type check - ensure it's a text channel that can send messages
262+
if not hasattr(channel, "send"):
263+
result["status"] = (
264+
f"Channel {channel_name} cannot receive messages (not a text channel)"
265+
)
266+
await client.close()
267+
return
268+
269+
# Split message into chunks if it exceeds 2000 characters
270+
chunks = self.chunk_message(message_content)
271+
last_message = None
272+
for chunk in chunks:
273+
last_message = await channel.send(chunk) # type: ignore
274+
result["status"] = "Message sent"
275+
result["message_id"] = str(last_message.id) if last_message else ""
276+
result["channel_id"] = str(channel.id)
253277
await client.close()
254278

255279
await client.start(token)

autogpt_platform/backend/backend/blocks/jina/fact_checker.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from typing import List
12
from urllib.parse import quote
23

4+
from typing_extensions import TypedDict
5+
36
from backend.blocks.jina._auth import (
47
JinaCredentials,
58
JinaCredentialsField,
@@ -10,6 +13,12 @@
1013
from backend.util.request import Requests
1114

1215

16+
class Reference(TypedDict):
17+
url: str
18+
keyQuote: str
19+
isSupportive: bool
20+
21+
1322
class FactCheckerBlock(Block):
1423
class Input(BlockSchema):
1524
statement: str = SchemaField(
@@ -23,6 +32,10 @@ class Output(BlockSchema):
2332
)
2433
result: bool = SchemaField(description="The result of the factuality check")
2534
reason: str = SchemaField(description="The reason for the factuality result")
35+
references: List[Reference] = SchemaField(
36+
description="List of references supporting or contradicting the statement",
37+
default=[],
38+
)
2639
error: str = SchemaField(description="Error message if the check fails")
2740

2841
def __init__(self):
@@ -53,5 +66,11 @@ async def run(
5366
yield "factuality", data["factuality"]
5467
yield "result", data["result"]
5568
yield "reason", data["reason"]
69+
70+
# Yield references if present in the response
71+
if "references" in data:
72+
yield "references", data["references"]
73+
else:
74+
yield "references", []
5675
else:
5776
raise RuntimeError(f"Expected 'data' key not found in response: {data}")

autogpt_platform/frontend/src/app/(platform)/library/components/LibraryUploadAgentDialog/useLibraryUploadAgentDialog.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const useLibraryUploadAgentDialog = () => {
8282
)
8383
) {
8484
throw new Error(
85-
"Invalid agent object in file: " + JSON.stringify(obj, null, 2),
85+
"Invalid agent file. Please upload a valid agent.json file that has been previously exported from the AutoGPT platform. The file must contain the required fields: name, description, nodes, and links.",
8686
);
8787
}
8888
const agent = obj as Graph;
@@ -96,6 +96,17 @@ export const useLibraryUploadAgentDialog = () => {
9696
}
9797
} catch (error) {
9898
console.error("Error loading agent file:", error);
99+
100+
toast({
101+
title: "Invalid Agent File",
102+
description:
103+
"Please upload a valid agent.json file that has been previously exported from the AutoGPT platform. The file must contain the required fields: name, description, nodes, and links.",
104+
duration: 5000,
105+
variant: "destructive",
106+
});
107+
108+
form.resetField("agentFile");
109+
setAgentObject(null);
99110
}
100111
};
101112
reader.readAsText(file);

docs/content/platform/blocks/discord.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The block uses a Discord bot to log into a server, locate the specified channel,
4343
|-------|-------------|
4444
| Discord Bot Token | A secret token used to authenticate the bot with Discord |
4545
| Message Content | The text content of the message to be sent |
46-
| Channel Name | The name of the Discord channel where the message should be sent |
46+
| Channel Name | Channel ID or channel name to send the message to |
4747

4848
### Outputs
4949
| Output | Description |

0 commit comments

Comments
 (0)