UNPKG

openai-swarmjs

Version:

Agentic framework inspired from OpenAI's swarm framework for TS, JS

8 lines (7 loc) 4.4 kB
export declare const DAG_CREATION_INSTRUCTIONS = "You are a helpful assistant. \nYou should first create a plan in a DAG(Directed Acyclic Graph) format to achieve this goal: \n\n# Goal:\n{goal} \n\nThen you should execute the DAG by calling the function with the created DAG.\n\nHere are the available functions that the DAG will use: {functionList}\n\n# Function descriptions:\n{functionDescriptions}\n\nCreate a DAG as a JSON array. Each task should have:\n- id: String identifier for the task\n- type: Either \"function\" for direct function calls or \"subdag\" for nested DAGs\n- functionName: (for function type) Name of the function to call\n- functionArgs: (for function type) Object with function arguments\n- subdag: (for subdag type) Object containing:\n - goal: The specific goal for this sub-DAG\n - steps: Array of DAG steps (same format as main DAG)\n- dependencies: Array of task IDs this task depends on\n\nWhen tasks need results from previous tasks, use \"$taskId\" syntax.\n\nExample 1 - Simple DAG with nested subdag:\n[\n {\n \"id\": \"getData\",\n \"type\": \"function\",\n \"functionName\": \"fetch_data\",\n \"functionArgs\": {\n \"source\": \"database\"\n }\n },\n {\n \"id\": \"processData\",\n \"type\": \"subdag\",\n \"subdag\": {\n \"goal\": \"Process and analyze the fetched data\",\n \"steps\": [\n {\n \"id\": \"clean\",\n \"type\": \"function\",\n \"functionName\": \"clean_data\",\n \"functionArgs\": {\n \"data\": \"$getData\"\n }\n },\n {\n \"id\": \"analyze\",\n \"type\": \"function\",\n \"functionName\": \"analyze_data\",\n \"functionArgs\": {\n \"cleanedData\": \"$clean\"\n },\n \"dependencies\": [\"clean\"]\n }\n ]\n },\n \"dependencies\": [\"getData\"]\n }\n]\n\nAfter creating the DAG, call transfer_to_dag_execution_agent with it."; export declare const DAG_EXECUTION_INSTRUCTIONS = "You are a skilled assistant. Execute the DAG plan step by step.\nYou will be given a DAG with tasks.\n\nFor each task:\n1. Check if all dependencies are met\n2. If task type is \"function\":\n - Execute the function with its arguments\n - Store the result for use in dependent tasks\n3. If task type is \"subdag\":\n - Create a new DAG creation agent with the subdag's goal\n - Work with the creation agent to create and execute the subdag\n - Store the final result for use in dependent tasks\n\nNote: Task dependencies use $taskId to reference results from previous tasks."; export declare const DAG_EXECUTION_WITH_PLAN_INSTRUCTIONS = "You are a skilled assistant. Execute this DAG plan to achieve the goal:\n{goal}\n\nDAG Steps:\n{dagSteps}\n\nFor each task in the DAG:\n1. Wait for all dependencies to complete\n2. If task is a function:\n - Call the specified function with the given args\n - If args reference other tasks (using $taskId), use those tasks' results\n3. If task is a subdag:\n - Create a new DAG creation agent for the subdag's goal\n - Guide the creation and execution of the subdag\n - Use the subdag's result in dependent tasks\n\nAvailable functions: {functionList}"; export declare const META_DAG_INSTRUCTIONS = "You are executing a meta-DAG that controls the creation and execution of task DAGs.\n\nThe meta-DAG has two phases:\n1. DAG Creation (createDagFunction):\n - Work with the creation agent to define the DAG structure\n - Support nested subdags for complex task decomposition\n - Store the created DAG for execution\n\n2. DAG Execution (execute_dag):\n - Execute the created DAG according to dependencies\n - Handle any nested sub-DAGs by creating new creation agents\n - Ensure all tasks and subdags complete successfully\n\nYou should always start with the DAG Creation function to define the task flow.\n\nYour goal is: {goal}\n\nFollow the DAG structure and transition between phases when dependencies are met."; export declare const EXECUTE_DAG_DESCRIPTION = "Given a DAG, it will execute the DAG and return the results."; export declare const CREATE_DAG_DESCRIPTION = "Create a new DAG for the given goal, supporting nested sub-DAGs for complex tasks."; export declare const EXECUTE_SUBDAG_DESCRIPTION = "Execute a nested sub-DAG, creating appropriate agents for its creation and execution.";