Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Jan 4, 2025
1 parent bc94e53 commit dd27edb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
43 changes: 42 additions & 1 deletion apps/shinkai-desktop/src/components/agent/agent-form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { PlusIcon } from '@radix-ui/react-icons';
import { useTranslation } from '@shinkai_network/shinkai-i18n';
import { JobConfig } from '@shinkai_network/shinkai-message-ts/api/jobs/types';
import { DEFAULT_CHAT_CONFIG } from '@shinkai_network/shinkai-node-state/v2/constants';
Expand All @@ -8,6 +9,7 @@ import { useGetAgent } from '@shinkai_network/shinkai-node-state/v2/queries/getA
import { useGetLLMProviders } from '@shinkai_network/shinkai-node-state/v2/queries/getLLMProviders/useGetLLMProviders';
import { useGetTools } from '@shinkai_network/shinkai-node-state/v2/queries/getToolsList/useGetToolsList';
import {
Badge,
Button,
Form,
FormControl,
Expand All @@ -34,15 +36,18 @@ import {
TooltipProvider,
TooltipTrigger,
} from '@shinkai_network/shinkai-ui';
import { FilesIcon } from '@shinkai_network/shinkai-ui/assets';
import { formatText } from '@shinkai_network/shinkai-ui/helpers';
import { BoltIcon, PlusIcon } from 'lucide-react';
import { cn } from '@shinkai_network/shinkai-ui/utils';
import { BoltIcon } from 'lucide-react';
import { InfoCircleIcon } from 'primereact/icons/infocircle';
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import { Link, useNavigate, useParams } from 'react-router-dom';
import { toast } from 'sonner';
import { z } from 'zod';

import { useSetJobScope } from '../../components/chat/context/set-job-scope-context';
import { SubpageLayout } from '../../pages/layout/simple-layout';
import { useAuth } from '../../store/auth';
import { useSettings } from '../../store/settings';
Expand Down Expand Up @@ -86,6 +91,8 @@ function AgentForm({ mode }: AgentFormProps) {
const auth = useAuth((state) => state.auth);
const navigate = useNavigate();
const { t } = useTranslation();
const setSetJobScopeOpen = useSetJobScope((state) => state.setSetJobScopeOpen);
const selectedKeys = useSetJobScope((state) => state.selectedKeys);

const { data: agent } = useGetAgent({
agentId: agentId ?? '',
Expand Down Expand Up @@ -679,6 +686,40 @@ function AgentForm({ mode }: AgentFormProps) {
/>
</div>
</div>

<div className="space-y-6 rounded-lg bg-gray-400 px-4 py-4 pb-7">
<span className="flex-1 items-center gap-1 truncate py-2 text-left text-xs font-semibold text-gray-50">
Agent Context
</span>

<div className="space-y-4">
<Button
className={cn(
'flex h-auto w-auto items-center gap-2 rounded-lg bg-gray-500 px-2.5 py-1.5',
)}
onClick={() => {
setSetJobScopeOpen(true);
}}
size="auto"
type="button"
variant="ghost"
>
<div className="flex items-center gap-2">
<FilesIcon className="h-4 w-4" />
<p className="text-xs text-white">{t('vectorFs.localFiles')}</p>
</div>
{Object.keys(selectedKeys || {}).length > 0 ? (
<Badge className="bg-brand inline-flex h-5 w-5 items-center justify-center rounded-full border-gray-200 p-0 text-center text-gray-50">
{Object.keys(selectedKeys || {}).length}
</Badge>
) : (
<Badge className="inline-flex h-5 w-5 items-center justify-center rounded-full border-gray-200 bg-gray-200 p-0 text-center text-gray-50">
<PlusIcon className="h-3.5 w-3.5" />
</Badge>
)}
</Button>
</div>
</div>
</div>
</div>
<div className="flex items-center justify-end gap-2">
Expand Down
26 changes: 24 additions & 2 deletions apps/shinkai-desktop/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { PlusIcon } from '@radix-ui/react-icons';
import { useTranslation } from '@shinkai_network/shinkai-i18n';
import { JobConfig } from '@shinkai_network/shinkai-message-ts/api/jobs/types';
import { DEFAULT_CHAT_CONFIG } from '@shinkai_network/shinkai-node-state/v2/constants';
import { useGetLLMProviders } from '@shinkai_network/shinkai-node-state/v2/queries/getLLMProviders/useGetLLMProviders';
import { TooltipProvider } from '@shinkai_network/shinkai-ui';
import { listen } from '@tauri-apps/api/event';
Expand Down Expand Up @@ -275,8 +279,26 @@ const AppRoutes = () => {
<Route element={<AIModelInstallation />} path="local-ais" />
<Route element={<AIsPage />} path="ais" />
<Route element={<AddAIPage />} path="add-ai" />
<Route element={<AddAgentPage />} path="add-agent" />
<Route element={<EditAgentPage />} path="/agents/edit/:agentId" />
<Route
element={
<VectorFsProvider>
<SetJobScopeProvider>
<AddAgentPage />
</SetJobScopeProvider>
</VectorFsProvider>
}
path="add-agent"
/>
<Route
element={
<VectorFsProvider>
<SetJobScopeProvider>
<EditAgentPage />
</SetJobScopeProvider>
</VectorFsProvider>
}
path="/agents/edit/:agentId"
/>
</Route>
<Route
element={
Expand Down

0 comments on commit dd27edb

Please sign in to comment.