Skip to content

Commit

Permalink
Merge pull request #548 from dcSpark/paulccari/update-use-tools
Browse files Browse the repository at this point in the history
fix: misc improvements
  • Loading branch information
nicarq authored Dec 3, 2024
2 parents c4da44e + a7a90b7 commit dd9c89e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/shinkai-desktop/src/components/agent/add-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function AddAgentPage() {
custom_prompt: '',
custom_system_prompt: '',
other_model_params: {},
use_tools: DEFAULT_CHAT_CONFIG.use_tools,
use_tools: true,
},
llmProviderId: defaultAgentId,
},
Expand Down
4 changes: 2 additions & 2 deletions apps/shinkai-desktop/src/pages/chat/empty-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const EmptyMessage = () => {
</Badge>
{[
{
text: 'Search in Perplexity',
prompt: 'Search in Perplexity for: ',
text: 'Search in DuckDuckGo',
prompt: 'Search in DuckDuckGo for: ',
},
{
text: 'Summarize a Youtube video',
Expand Down
23 changes: 19 additions & 4 deletions apps/shinkai-desktop/src/pages/layout/main-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ const ResetConnectionDialog = ({
isOpen: boolean;
onOpenChange: (open: boolean) => void;
}) => {
const { mutateAsync: shinkaiNodeKill } = useShinkaiNodeKillMutation();
const { mutateAsync: shinkaiNodeSpawn } = useShinkaiNodeSpawnMutation({
const { mutateAsync: shinkaiNodeKill, isPending: isShinkaiNodeKillPending } =
useShinkaiNodeKillMutation();
const {
mutateAsync: shinkaiNodeSpawn,
isPending: isShinkaiNodeSpawnPending,
} = useShinkaiNodeSpawnMutation({
onSuccess: async () => {
if (!encryptionKeys) return;
await submitRegistrationNoCode({
Expand All @@ -195,13 +199,20 @@ const ResetConnectionDialog = ({
});
},
});
const { mutateAsync: shinkaiNodeRemoveStorage } =
useShinkaiNodeRemoveStorageMutation();
const {
mutateAsync: shinkaiNodeRemoveStorage,
isPending: isShinkaiNodeRemoveStoragePending,
} = useShinkaiNodeRemoveStorageMutation();
const { setShinkaiNodeOptions } = useShinkaiNodeManager();
const { encryptionKeys } = useGetEncryptionKeys();
const setAuth = useAuth((state) => state.setAuth);
const navigate = useNavigate();

const isResetLoading =
isShinkaiNodeKillPending ||
isShinkaiNodeRemoveStoragePending ||
isShinkaiNodeSpawnPending;

const { mutateAsync: submitRegistrationNoCode } = useSubmitRegistrationNoCode(
{
onSuccess: (response, setupPayload) => {
Expand Down Expand Up @@ -254,6 +265,8 @@ const ResetConnectionDialog = ({
<AlertDialogFooter className="mt-4 flex items-center justify-end gap-2.5">
<Button
className="min-w-32 text-sm"
disabled={isResetLoading}
isLoading={isResetLoading}
onClick={handleReset}
size="sm"
variant={'destructive'}
Expand Down Expand Up @@ -627,6 +640,8 @@ const MainLayout = () => {
}
if (isSuccess && nodeInfo?.update_requires_reset) {
setNeedsResetApp(true);
} else {
setNeedsResetApp(false);
}
}, [isSuccess, nodeInfo?.status, isFetching]);

Expand Down
5 changes: 4 additions & 1 deletion libs/shinkai-message-ts/src/api/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
GetPlaygroundToolsResponse,
GetToolResponse,
GetToolsResponse,
GetToolsSearchResponse,
PayInvoiceRequest,
SaveToolCodeRequest,
SaveToolCodeResponse,
Expand Down Expand Up @@ -86,7 +87,9 @@ export const searchTools = async (
responseType: 'json',
},
);
return response.data as GetToolsResponse;
const data = response.data as GetToolsSearchResponse;
const formattedData = data.map(([header]) => header);
return formattedData as GetToolsResponse;
};

export const updateTool = async (
Expand Down
1 change: 1 addition & 0 deletions libs/shinkai-message-ts/src/api/tools/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export type GetToolResponse = {
type: ShinkaiToolType;
};
export type GetToolsResponse = ShinkaiToolHeader[];
export type GetToolsSearchResponse = [ShinkaiToolHeader, number][];

export type AddToolRequest = {
type: ShinkaiToolType;
Expand Down
2 changes: 1 addition & 1 deletion libs/shinkai-node-state/src/v2/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const DEFAULT_CHAT_CONFIG = {
top_k: 40,
top_p: 0.9,
stream: true,
use_tools: true,
use_tools: false,
} as const;

export const OPTIMISTIC_USER_MESSAGE_ID = 'OPTIMISTIC_USER_MESSAGE_ID';
Expand Down

0 comments on commit dd9c89e

Please sign in to comment.