Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/mail/components/ui/ai-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ function AISidebar({ className }: AISidebarProps) {
});

const chatState = useAgentChat({
getInitialMessages: async () => {
return [];
},
agent,
maxSteps: 10,
body: {
Expand Down Expand Up @@ -470,7 +473,7 @@ function AISidebar({ className }: AISidebarProps) {
<div
tabIndex={0}
className={cn(
'fixed inset-0 z-50 flex items-center justify-center bg-transparent p-4 lg:opacity-40 backdrop-blur-sm transition-opacity duration-150 lg:hover:opacity-100 sm:inset-auto sm:bottom-4 sm:right-4 sm:flex-col sm:items-end sm:justify-end sm:p-0',
'fixed inset-0 z-50 flex items-center justify-center bg-transparent p-4 backdrop-blur-sm transition-opacity duration-150 sm:inset-auto sm:bottom-4 sm:right-4 sm:flex-col sm:items-end sm:justify-end sm:p-0 lg:opacity-40 lg:hover:opacity-100',
'md:hidden',
isPopup && !isFullScreen && 'md:flex',
isFullScreen && '!inset-0 !flex !p-0 !opacity-100 !backdrop-blur-none',
Expand Down
21 changes: 19 additions & 2 deletions apps/server/src/routes/agent/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { composeEmail } from '../../trpc/routes/ai/compose';
import { perplexity } from '@ai-sdk/perplexity';
import { generateText, tool } from 'ai';

import { colors } from '../../lib/prompts';
import { colors, GmailSearchAssistantSystemPrompt } from '../../lib/prompts';
import { anthropic } from '@ai-sdk/anthropic';
import { env } from 'cloudflare:workers';
import type { ZeroAgent } from '../chat';
import { Tools } from '../../types';
Expand Down Expand Up @@ -380,6 +381,22 @@ export const webSearch = () =>
},
});

const buildGmailSearchQuery = () =>
tool({
description: 'Build Gmail search query using AI assistance',
parameters: z.object({
query: z.string(),
}),
execute: async ({ query }) => {
const result = await generateText({
model: anthropic(env.OPENAI_MODEL || 'claude-3-5-haiku-latest'),
system: GmailSearchAssistantSystemPrompt(),
prompt: query,
});
return result.text;
},
});

export const tools = async (agent: ZeroAgent, connectionId: string) => {
return {
[Tools.GetThread]: getEmail(agent),
Expand All @@ -399,13 +416,13 @@ export const tools = async (agent: ZeroAgent, connectionId: string) => {
query: z.string().describe('The query to search the web for'),
}),
}),
[Tools.BuildGmailSearchQuery]: buildGmailSearchQuery(),
[Tools.InboxRag]: tool({
description:
'Search the inbox for emails using natural language. Returns only an array of threadIds.',
parameters: z.object({
query: z.string().describe('The query to search the inbox for'),
}),
}),
// ...(await getGoogleTools(connectionId)),
};
};
Loading