ai agent update

This commit is contained in:
Harivansh Rathi 2024-12-09 13:58:19 -05:00
parent 4347289246
commit a241013966
2 changed files with 37 additions and 2 deletions

2
.env
View file

@ -2,7 +2,7 @@ VITE_SUPABASE_URL=https://nvatjthzedykhikmttot.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im52YXRqdGh6ZWR5a2hpa210dG90Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzM1OTYxOTMsImV4cCI6MjA0OTE3MjE5M30.u4euR8U-XxxvOdLFmWJD2yrd4E_MPMt_X1yqRrDTF2I
# N8N Configuration
VITE_N8N_WEBHOOK_URL=https://harivansh.app.n8n.cloud/webhook-test/chat-webhook
VITE_N8N_WEBHOOK_URL=https://harivansh.app.n8n.cloud/webhook/chat-webhook
VITE_N8N_UPLOAD_WEBHOOK_URL=https://harivansh.app.n8n.cloud/webhook/upload-webhook
# Google Drive Configuration

View file

@ -37,12 +37,27 @@ function extractCitations(content: string): { cleanContent: string; citations: C
return { cleanContent, citations };
}
function extractUsedTool(content: string): { cleanContent: string; usedTools: string[] } {
const usedToolRegex = /^\*\*Used Tool(?:s)?: ([^*]+)\*\*\n\n/;
const match = content.match(usedToolRegex);
if (match) {
const usedToolsString = match[1];
const usedTools = usedToolsString.split(',').map(tool => tool.trim());
const cleanContent = content.replace(usedToolRegex, '');
return { cleanContent, usedTools };
}
return { cleanContent: content, usedTools: [] };
}
export function Message({ message }: MessageProps) {
const [copied, setCopied] = React.useState(false);
const [messageCopied, setMessageCopied] = React.useState(false);
const [isLiked, setIsLiked] = React.useState(false);
const [isDisliked, setIsDisliked] = React.useState(false);
const { cleanContent, citations } = extractCitations(message.content);
const { cleanContent: finalContent, usedTools } = extractUsedTool(cleanContent);
const handleCopy = async (text: string) => {
await navigator.clipboard.writeText(text);
@ -175,7 +190,7 @@ export function Message({ message }: MessageProps) {
)}
components={components}
>
{cleanContent}
{finalContent}
</ReactMarkdown>
{message.role === 'assistant' && citations.length > 0 && (
@ -197,6 +212,26 @@ export function Message({ message }: MessageProps) {
</div>
</>
)}
{message.role === 'assistant' && usedTools.length > 0 && (
<>
<Separator className="my-4 opacity-30" />
<div className="flex flex-col gap-2">
<div className="flex items-center gap-2 text-xs font-medium text-muted-foreground/80">
<BookOpen className="h-4 w-4" />
Used Tools
</div>
{usedTools.map((tool, index) => (
<div key={index} className="flex items-start gap-2 text-xs">
<LinkIcon className="h-3 w-3 mt-0.5 text-muted-foreground/70" />
<span className="text-muted-foreground/70">
{tool}
</span>
</div>
))}
</div>
</>
)}
</div>
<div className="flex items-center gap-4 text-xs">