Skip to content

Commit

Permalink
Merge pull request #191 from autonomys/feat/getTimeTool
Browse files Browse the repository at this point in the history
Add tool for retrieving current time
  • Loading branch information
jfrank-summit authored Jan 30, 2025
2 parents 443ed10 + 6758516 commit 0fcb1f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autonomys-agents",
"version": "0.2.0",
"version": "0.2.1",
"description": "Autonomys Agents",
"main": "dist/index.js",
"type": "module",
Expand Down
12 changes: 12 additions & 0 deletions src/agents/tools/getTimeTool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DynamicStructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
export const createGetCurrentTimeTool = () =>
new DynamicStructuredTool({
name: 'get_current_time',
description:
'Returns the current real-world time. Use this whenever you need to know the current time, make scheduling decisions, or calculate time differences. The time is returned in ISO format. This is the only way to get accurate current time information.',
schema: z.object({}),
func: async () => {
return new Date().toISOString();
},
});
5 changes: 4 additions & 1 deletion src/agents/workflows/orchestrator/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ import { createVectorDbInsertTool, createVectorDbSearchTool } from '../../tools/
import { TwitterApi } from '../../../services/twitter/types.js';
import { VectorDB } from '../../../services/vectorDb/VectorDB.js';
import { createSaveExperienceTool } from '../../tools/saveExperienceTool.js';

import { createGetCurrentTimeTool } from '../../tools/getTimeTool.js';
export const createTools = (twitterApi: TwitterApi, vectorDb: VectorDB) => {
const twitterWorkflowTool = createTwitterWorkflowTool();
const twitterTools = createAllTwitterTools(twitterApi);
const vectorDbSearchTool = createVectorDbSearchTool(vectorDb);
const vectorDbInsertTool = createVectorDbInsertTool(vectorDb);
const saveExperienceTool = createSaveExperienceTool();
const getCurrentTimeTool = createGetCurrentTimeTool();

return {
...twitterTools,
twitterWorkflowTool,
vectorDbSearchTool,
vectorDbInsertTool,
saveExperienceTool,
getCurrentTimeTool,
tools: [
...twitterTools.tools,
twitterWorkflowTool,
vectorDbSearchTool,
vectorDbInsertTool,
saveExperienceTool,
getCurrentTimeTool,
],
};
};
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ process.on('SIGTERM', () => {
const startWorkflowPolling = async () => {
try {
const _result = await runOrchestratorWorkflow(
`You are expected to run the twitter workflow periodically in order to maintain social engagement. The current date and time is ${new Date().toISOString()}`,
`You are expected to run the twitter workflow periodically in order to maintain social engagement.`,
);

logger.info('Workflow execution completed successfully for character:', {
Expand Down

0 comments on commit 0fcb1f2

Please sign in to comment.