Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for customizable prompt templates #208

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jfrank-summit
Copy link
Member

This pull request includes significant changes to the prompt creation and orchestration workflow in the codebase. The changes focus on refactoring the prompt creation logic, improving the descriptions for tools, and enhancing the orchestration workflow by introducing new prompt templates and better handling of custom instructions.

Refactoring and Improvements:

  • Prompt Creation Refactoring:

    • Moved the creation of input, message summary, and workflow summary prompts to separate files (inputPrompt.js, messageSummaryPrompt.js, workflowSummaryPrompt.js) and updated the import paths accordingly. ([[1]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-b4dfd7878eec16efd1a0380da0464e07cc47af54ed1dc55b5fc0aefef7644059L21-R21), [[2]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-d54f03d74b8d197391b49044b4557e75108a9f7d4c8800480b843439aedf7ad6L1-L96))
    • Updated the createPrompts function to include custom instructions for each type of prompt and return an OrchestratorPrompts object. ([src/agents/workflows/orchestrator/prompts.tsL1-L94](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-898d517c9ce0d630ebd6fb1a6f31566f2fea89416af8a57a91686c7440875f81L1-L94))
  • Enhanced Tool Descriptions:

    • Improved the description of the createFetchMyRecentTweetsAndRepliesTool to provide better context on its usage. ([src/agents/tools/twitterTools.tsL116-R117](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-230c660f4e65058334d197eecd5d08fa4631f93b723a7648314029959f810c75L116-R117))

Orchestration Workflow Enhancements:

  • New Prompt Templates:

    • Added a new createInputPrompt function to generate input prompts with detailed instructions and memory management rules. ([src/agents/workflows/orchestrator/nodes/inputPrompt.tsR1-R64](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-b2e08db2b9f277c67d3851b990977574059546cf698db5688d8237a7a55d7669R1-R64))
    • Introduced a createMessageSummaryPrompt function to create detailed message summary prompts that preserve all information conveyed in the messages. ([src/agents/workflows/orchestrator/nodes/messageSummaryPrompt.tsR1-R44](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-7039098758f1907ccdf2759222c92945afeb8af3dd5d6d02e15dd0c23afcdd3fR1-R44))
    • Created a createWorkflowSummaryPrompt function to generate workflow summary prompts that summarize messages in detail without recommending tool usage. ([src/agents/workflows/orchestrator/nodes/workflowSummaryPrompt.tsR1-R35](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-dc9d6e08725c40786fd5ba7e17499fdeb01e6eb1f83549e6a7f573248e1d6d99R1-R35))
  • Orchestrator Workflow Updates:

    • Updated the orchestrator configuration to include the new prompt templates and adjusted the function calls to use the new prompt names (messageSummaryPrompt and workflowSummaryPrompt). ([[1]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-49cc4f0909411e6de89a20d5a97f81c481546b48973288ba70aeb002b0dd4138L5-R19), [[2]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-8712f0e470d012359def290bb6cb8e4cad477279c8a885cb5b96ca7152bc3ffdL27-R27), [[3]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-b6e31d4ab6330f226a3a8396df55104e1543df617820358ac0a8f4d3a525eff9R17-R24))
    • Refactored the twitter agent tool to use the new createTwitterPrompts function, which includes custom instructions specific to the Twitter workflow. ([[1]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-b50553d9a14cebc922dbd73f76ea0d585fe039df73270d725f01317ad0d668b3L4-R4), [[2]](https://github.com/autonomys/autonomys-agents/pull/208/files#diff-b50553d9a14cebc922dbd73f76ea0d585fe039df73270d725f01317ad0d668b3L21-R21))

These changes collectively improve the modularity, readability, and functionality of the prompt creation and orchestration workflow in the codebase.

Closes #205

@jfrank-summit jfrank-summit requested a review from Xm0onh February 5, 2025 01:15
Copy link
Member

@Xm0onh Xm0onh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Just dropped some comments and suggestions.

Comment on lines +58 to +64

export const workflowControlParser = z.object({
shouldStop: z.boolean(),
reason: z.string(),
});

export type WorkflowControl = z.infer<typeof workflowControlParser>;
Copy link
Member

@Xm0onh Xm0onh Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are organizing prompts, can we move this to a separate file? does it make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd that we have prompts.ts that is reading from node folder.
I suggest to have a prompt folder and move all the prompts there and rename this file to promptsGenerator.ts or other descriptive name that you find best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Prompt Templating Process
2 participants