A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: api keys panel
dextmorgn5337de1761a1
diff --git a/package.json b/package.jsonindex b0556b1d..c58a4548 100644--- a/package.json+++ b/package.json@@ -9,9 +9,11 @@"lint": "eslint . --ext .ts,.tsx -c .eslintrc.json --fix"},"dependencies": {+ "@ai-sdk/mistral": "^1.1.8","@ai-sdk/openai": "^1.1.9","@dagrejs/dagre": "^1.1.4","@internationalized/date": "^3.7.0",+ "@mistralai/mistralai": "^1.5.0","@radix-ui/react-icons": "^1.3.2","@radix-ui/themes": "^3.2.0","@react-aria/ssr": "3.9.7",diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.tsindex 5ac814f6..1b8ca12f 100644--- a/src/app/api/chat/route.ts+++ b/src/app/api/chat/route.ts@@ -1,4 +1,4 @@-import { openai } from '@ai-sdk/openai';+import { mistral } from '@ai-sdk/mistral';import { streamText } from 'ai';// Allow streaming responses up to 30 seconds@@ -8,7 +8,7 @@ export async function POST(req: Request) {const { messages } = await req.json();const result = streamText({- model: openai('gpt-4o-mini'),+ model: mistral('mistral-tiny'),messages,});diff --git a/src/app/dashboard/keys/page.tsx b/src/app/dashboard/keys/page.tsxnew file mode 100644index 00000000..0c043257--- /dev/null+++ b/src/app/dashboard/keys/page.tsx@@ -0,0 +1,65 @@+import { Button, Card, IconButton, Separator, Table, Tabs } from "@radix-ui/themes"+import { Trash2 } from 'lucide-react'++export default function APIKeys() {+ return (+ <div className="max-w-6xl mx-auto p-6">+ <div className="flex flex-col justify-between items-start mb-4">+ <div className="flex justify-between w-full items-center">+ <div>+ <h1 className="text-3xl font-semibold mb-2">Vos clés API</h1>+ <p className="mb-6">+ Gérez vos clés API personnelles pour l'espace de travail Espace de travail de Eliott Morcillo.+ </p>+ </div>+ <Button+ >+ Créer une nouvelle clé+ </Button>+ </div>+ <Separator className='w-full' size={"4"} />+ <p className="mb-8 mt-4">+ Vous pouvez créer jusqu'à 10 clés API et les supprimer lorsque vous n'en avez plus besoin.+ </p>+ </div>+ <Tabs.Root defaultValue="active" className="mb-3">+ <Tabs.List>+ <Tabs.Trigger+ value="active"+ >+ Actif+ </Tabs.Trigger>+ <Tabs.Trigger+ value="expired"+ >+ Expiré+ </Tabs.Trigger>+ </Tabs.List>+ </Tabs.Root>+ <Card>+ <Table.Root>+ <Table.Header>+ <Table.Row>+ <Table.ColumnHeaderCell className="w-[300px]">Nom</Table.ColumnHeaderCell>+ <Table.ColumnHeaderCell>Clé</Table.ColumnHeaderCell>+ <Table.ColumnHeaderCell className="text-right">Date d'expiration</Table.ColumnHeaderCell>+ <Table.ColumnHeaderCell className="w-[50px]"></Table.ColumnHeaderCell>+ </Table.Row>+ </Table.Header>+ <Table.Body>+ <Table.Row>+ <Table.RowHeaderCell>clé d'essai</Table.RowHeaderCell>+ <Table.Cell className="font-mono">************************pnA5</Table.Cell>+ <Table.Cell className="text-right">15 février 2025</Table.Cell>+ <Table.Cell>+ <IconButton variant="ghost">+ <Trash2 className="h-4 w-4" />+ </IconButton>+ </Table.Cell>+ </Table.Row>+ </Table.Body>+ </Table.Root>+ </Card>+ </div>+ )+}diff --git a/src/components/contexts/chatbot-context.tsx b/src/components/contexts/chatbot-context.tsxindex a04e0a8c..f4bd07c0 100644--- a/src/components/contexts/chatbot-context.tsx+++ b/src/components/contexts/chatbot-context.tsx@@ -1,6 +1,6 @@'use client';-import { createContext, ReactNode, useContext, useState } from 'react';+import { createContext, ReactNode, useContext, useEffect, useState } from 'react';import { Avatar, Box, Card, Dialog, Flex, Spinner, Text, TextArea, TextField } from '@radix-ui/themes';import { useChat } from '@ai-sdk/react';import { BotIcon } from 'lucide-react';@@ -22,62 +22,7 @@ interface ChatProviderProps {export const ChatProvider: React.FC<ChatProviderProps> = ({ children }) => {const [open, setOpen] = useState(false);const { messages, input, handleInputChange, handleSubmit, error, isLoading } = useChat();- console.log(messages)- const du = [- {- "id": "KiYOaqV7dMH3suuG",- "createdAt": "2025-02-10T13:43:08.269Z",- "role": "user",- "content": "How can I assist you today? The data you provide is used to help OpenAI train for you",- "parts": [- {- "type": "text",- "text": "Hi !"- }- ]- },- {- "id": "msg-ypC3dSAKxps7AdstARujIElS",- "createdAt": "2025-02-10T13:43:08.890Z",- "role": "assistant",- "content": "Hello! How can I assist you today? The data you provide is used to help OpenAI train the ChatGPT model to become better at answering questions and helping users. With OpenAI collecting and storing identifying information about you and the user content you submit, countless companies across the world have moved to ban employees from using it. However, at Forcepoint, we don’t think that’s the right move.",- "parts": [- {- "type": "text",- "text": "Hello! How can I assist you today?"- }- ],- "revisionId": "KEMTqIzqfLQVvgaP"- }- ]- const su = [- {- "id": "gyHIBSO61JMvlVh9",- "createdAt": "2025-02-10T13:58:53.588Z",- "role": "user",- "content": "Hey ! Could you help me with something ?",- "parts": [- {- "type": "text",- "text": "Hey ! Could you help me with something ?"- }- ]- },- {- "id": "msg-qgrLAn4cLwax0xgYcum7JFoj",- "createdAt": "2025-02-10T13:58:54.230Z",- "role": "assistant",- "content": "Of course! What do you need help with?",- "parts": [- {- "type": "text",- "text": "Of course! What do you need help with?"- }- ],- "revisionId": "JydtwMc56LdZIkoT"- }- ]return (<ChatContext.Provider value={{ open, setOpen }}>{children}@@ -98,7 +43,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({ children }) => {/><Flex direction={"column"} align={m.role === 'user' ? 'end' : 'start'} gap="1" className='w-full'><Text size="2" as='div' weight="bold" className={cn(m.role === 'user' ? 'text-right' : 'text-left')}>- {m.role === 'user' ? 'User' : 'Chatbot'}+ {isLoading ? <LoadingDots /> : m.role === 'user' ? 'User' : 'Chatbot'}</Text><Card className='max-w-[80%]'><Box>@@ -126,7 +71,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({ children }) => {<Card className='max-w-[70%]'><Box><Text as="div" size="2" color="red">- {"Oops, an error occured. Make sure you provided a valid OpenAI API key."}+ {"Oops, an error occured. Make sure you provided a valid Mistral API key."}</Text></Box></Card>@@ -153,4 +98,33 @@ export const useChatContext = (): ChatContextType => {throw new Error("useChatContext must be used within a ChatProvider");}return context;-};\ No newline at end of file+};++interface LoadingDotsProps {+ speed?: number+ text?: string+}++const LoadingDots: React.FC<LoadingDotsProps> = ({ speed = 200, text = "Thinking" }) => {+ const [dots, setDots] = useState("")++ useEffect(() => {+ const interval = setInterval(() => {+ setDots((prevDots) => {+ if (prevDots.length >= 3) {+ return ""+ }+ return prevDots + "."+ })+ }, speed)++ return () => clearInterval(interval)+ }, [speed])++ return (+ <div className="flex items-center">+ <span>{text}</span>+ <span className="w-8 text-left">{dots}</span>+ </div>+ )+}\ No newline at end of filediff --git a/src/components/investigations/nodes/individual.tsx b/src/components/investigations/nodes/individual.tsxindex 7cc698d2..c21b4aa0 100644--- a/src/components/investigations/nodes/individual.tsx+++ b/src/components/investigations/nodes/individual.tsx@@ -27,8 +27,8 @@ function Custom(props: any) {><Card data-radius='full' className='!p-1'><Flex gap={"1"}>- <Button variant='soft' onClick={() => handleOpenIndividualModal(data.id)}><EditIcon className='h-4 w-4' />Edit</Button>- <Button variant='soft' onClick={() => setOpenChat(true)}><ZapIcon color='orange' className='h-4 w-4' />Ask AI</Button>+ <Button variant='soft' color='gray' onClick={() => handleOpenIndividualModal(data.id)}><EditIcon className='h-4 w-4' />Edit</Button>+ <Button variant='soft' color='gray' onClick={() => setOpenChat(true)}><ZapIcon color='orange' className='h-4 w-4' />Ask AI</Button></Flex></Card></NodeToolbar>}diff --git a/yarn.lock b/yarn.lockindex 6b3eb04d..cb20b693 100644--- a/yarn.lock+++ b/yarn.lock@@ -2,6 +2,14 @@# yarn lockfile v1+"@ai-sdk/mistral@^1.1.8":+ version "1.1.8"+ resolved "https://registry.yarnpkg.com/@ai-sdk/mistral/-/mistral-1.1.8.tgz#90e970a6dcc06f3e73f27d60e71a6df5ea13eaa8"+ integrity sha512-8KeDekwsjqh6TyqvgieIeOLO2uQvWI/Eynn1oG9qsxwo+B6+IdKSUsaBspAIOw1vQUn38mn9DixSRDog+9dhrQ==+ dependencies:+ "@ai-sdk/provider" "1.0.7"+ "@ai-sdk/provider-utils" "2.1.6"+"@ai-sdk/openai@^1.1.9":version "1.1.9"resolved "https://registry.yarnpkg.com/@ai-sdk/openai/-/openai-1.1.9.tgz#8ea8a7403b70fafcefe0dbfe9e4170148e5109ce"@@ -317,6 +325,13 @@dependencies:"@swc/helpers" "^0.5.0"+"@mistralai/mistralai@^1.5.0":+ version "1.5.0"+ resolved "https://registry.yarnpkg.com/@mistralai/mistralai/-/mistralai-1.5.0.tgz#c278e5f1909d5882de4c38effec3685a02c8002b"+ integrity sha512-AIn8pwAwA/fDvEUvmkt+40zH1ZmfaG3Q7oUWl17GUEC1tU7ZPwYz8Cv9P59lyS1SisHdDSu81oknO7f1ywkz8Q==+ dependencies:+ zod-to-json-schema "^3.24.1"+"@next/[email protected]":version "15.1.6"resolved "https://registry.yarnpkg.com/@next/env/-/env-15.1.6.tgz#2fa863d8c568a56b1c8328a86e621b8bdd4f2a20"