AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(backend): improve gmail blocks (#10475)
Nicholas Tindle95650ee34681
diff --git a/autogpt_platform/backend/backend/blocks/google/gmail.py b/autogpt_platform/backend/backend/blocks/google/gmail.pyindex 0ae42d09a0..a341d255e8 100644--- a/autogpt_platform/backend/backend/blocks/google/gmail.py+++ b/autogpt_platform/backend/backend/blocks/google/gmail.py@@ -32,6 +32,7 @@ class Attachment(BaseModel):class Email(BaseModel):threadId: str+ labelIds: list[str]id: strsubject: strsnippet: str@@ -49,6 +50,16 @@ class Thread(BaseModel):historyId: str+class GmailSendResult(BaseModel):+ id: str+ status: str+++class GmailLabelResult(BaseModel):+ label_id: str+ status: str++class GmailReadBlock(Block):class Input(BlockSchema):credentials: GoogleCredentialsInput = GoogleCredentialsField(@@ -93,6 +104,7 @@ class GmailReadBlock(Block):"email",{"threadId": "t1",+ "labelIds": ["INBOX"],"id": "1","subject": "Test Email","snippet": "This is a test email",@@ -109,6 +121,7 @@ class GmailReadBlock(Block):[{"threadId": "t1",+ "labelIds": ["INBOX"],"id": "1","subject": "Test Email","snippet": "This is a test email",@@ -126,6 +139,7 @@ class GmailReadBlock(Block):"_read_emails": lambda *args, **kwargs: [{"threadId": "t1",+ "labelIds": ["INBOX"],"id": "1","subject": "Test Email","snippet": "This is a test email",@@ -214,6 +228,7 @@ class GmailReadBlock(Block):email = Email(threadId=msg["threadId"],+ labelIds=msg.get("labelIds", []),id=msg["id"],subject=headers.get("subject", "No Subject"),snippet=msg["snippet"],@@ -347,7 +362,7 @@ class GmailSendBlock(Block):)class Output(BlockSchema):- result: dict = SchemaField(+ result: GmailSendResult = SchemaField(description="Send confirmation",)error: str = SchemaField(@@ -478,7 +493,7 @@ class GmailAddLabelBlock(Block):)class Output(BlockSchema):- result: dict = SchemaField(+ result: GmailLabelResult = SchemaField(description="Label addition result",)error: str = SchemaField(@@ -563,7 +578,7 @@ class GmailRemoveLabelBlock(Block):)class Output(BlockSchema):- result: dict = SchemaField(+ result: GmailLabelResult = SchemaField(description="Label removal result",)error: str = SchemaField(@@ -664,6 +679,7 @@ class GmailGetThreadBlock(Block):"snippet": "have a funny looking car -- Bently, Community Administrator For AutoGPT","subject": "car","threadId": "188199feff9dc907",+ "labelIds": ["INBOX"],"attachments": [{"size": 5694,@@ -692,6 +708,7 @@ class GmailGetThreadBlock(Block):"snippet": "have a funny looking car -- Bently, Community Administrator For AutoGPT","subject": "car","threadId": "188199feff9dc907",+ "labelIds": ["INBOX"],"attachments": [{"size": 5694,@@ -739,6 +756,7 @@ class GmailGetThreadBlock(Block):attachments = self._get_attachments(service, msg)email = Email(threadId=msg.get("threadId", thread_id),+ labelIds=msg.get("labelIds", []),id=msg["id"],subject=headers.get("subject", "No Subject"),snippet=msg.get("snippet", ""),diff --git a/autogpt_platform/backend/backend/blocks/smart_decision_maker.py b/autogpt_platform/backend/backend/blocks/smart_decision_maker.pyindex 5227d1f760..16642cece7 100644--- a/autogpt_platform/backend/backend/blocks/smart_decision_maker.py+++ b/autogpt_platform/backend/backend/blocks/smart_decision_maker.py@@ -520,6 +520,15 @@ class SmartDecisionMakerBlock(Block):parallel_tool_calls=input_data.multiple_tool_calls,)+ # Add reasoning to conversation history if available+ if response.reasoning:+ prompt.append(+ {"role": "assistant", "content": f"[Reasoning]: {response.reasoning}"}+ )++ prompt.append(response.raw_response)+ yield "conversations", prompt+if not response.tool_calls:yield "finished", response.responsereturn@@ -553,12 +562,3 @@ class SmartDecisionMakerBlock(Block):yield f"tools_^_{tool_name}_~_{arg_name}", tool_args[arg_name]else:yield f"tools_^_{tool_name}_~_{arg_name}", None-- # Add reasoning to conversation history if available- if response.reasoning:- prompt.append(- {"role": "assistant", "content": f"[Reasoning]: {response.reasoning}"}- )-- prompt.append(response.raw_response)- yield "conversations", prompt