UNPKG

@obayd/agentic

Version:

A powerful agent framework for LLMs.

57 lines (41 loc) 4.31 kB
// src/lib/prompts.js export const FUNCTION_PROMPT = `You have the ability to invoke external functions when necessary. To do so, respond *only* with a function call block using the special <%FUNCTAG% ... </%FUNCTAG%> tags in the following format: <%FUNCTAG% callId="UNIQUE_CALL_ID" name="FUNCTION_NAME" param1="value1" param2='{"json": "value"}' booleanParam=true numberParam=123>OPTIONAL_RAW_TEXT</%FUNCTAG%> - Replace UNIQUE_CALL_ID with a unique identifier for this specific call (e.g., "call_abc123"). THIS IS CRITICAL. - Replace FUNCTION_NAME with the exact name of the function to call from the list below. - Include parameters as XML-like attributes inside the opening <%FUNCTAG%> tag. Values *must* be valid JSON representations (strings enclosed in double or single quotes, numbers/booleans unquoted, objects/arrays represented as JSON strings within quotes like '{"key": "value"}' or '[1, 2]'). Ensure proper quoting, especially for strings containing special characters. If a function requires no parameters, omit attributes other than callId and name. - OPTIONAL_RAW_TEXT is any raw text input for the function, placed between the opening <%FUNCTAG% ...> and closing </%FUNCTAG%> tags. If the function does not use raw text input, ensure there is NOTHING between the tags: <%FUNCTAG% callId="call_xyz789" name="some_func" param="value"></%FUNCTAG%>. - Your response MUST contain ONLY the single function call block using <%FUNCTAG%> tags when you decide to call a function. Do NOT include any other text, explanations, introductions, or conversational filler before or after the block. The system will process the function call and provide the result in a subsequent user message using a corresponding <%RESULTTAG% ... </%RESULTTAG%> tag format, like this: <%RESULTTAG% callId="UNIQUE_CALL_ID" status="success|error">RESULT_JSON_STRING_OR_ERROR_MESSAGE</%RESULTTAG%> Never ask for confirmation before calling tools, go non-stop. You MUST wait for this <%RESULTTAG%> message in the next user turn before continuing the conversation based on the function's outcome. Do not assume the result or proceed without it. Example 1 (No Params, No Raw): User: What time is it? Assistant: <%FUNCTAG% callId="time_req_1" name="get_current_time"></%FUNCTAG%> User: <%RESULTTAG% callId="time_req_1" status="success">"2024-07-29T12:00:00Z"</%RESULTTAG%> Assistant: The current time is 12:00 PM UTC. Example 2 (With Params, No Raw): User: Search for 'AI assistants'. Assistant: <%FUNCTAG% callId="search_a1" name="web_search" query="AI assistants" limit=3></%FUNCTAG%> User: <%RESULTTAG% callId="search_a1" status="success">[{"title": "...", "url": "..."}]</%RESULTTAG%> Assistant: Here are the top 3 search results for 'AI assistants': ... Example 3 (With Params and Raw): User: Summarize: The rain in Spain stays mainly in the plain. Assistant: <%FUNCTAG% callId="sum_01" name="summarize" max_words=10>The rain in Spain stays mainly in the plain.</%FUNCTAG%> User: <%RESULTTAG% callId="sum_01" status="success">"Rain stays mostly on Spain's plain."</%RESULTTAG%> Assistant: Summary: Rain stays mostly on Spain's plain. Example 4 (Error): User: Use a non-existent tool. Assistant: <%FUNCTAG% callId="err_1" name="non_existent_tool"></%FUNCTAG%> User: <%RESULTTAG% callId="err_1" status="error">{"error":"Function 'non_existent_tool' not found or not enabled."}</%RESULTTAG%> Assistant: Apologies, I cannot perform that action as the tool 'non_existent_tool' is not available. Available functions: %FUNCTIONS%`; export const TOOLPACKS_PROMPT = ` You also have access to toolpacks, which group related functions. You can enable a toolpack using the 'enable_toolpack' function. IMPORTANT: 1. Call 'enable_toolpack' using the <%FUNCTAG%> format with the exact toolpack name: <%FUNCTAG% callId="tp_enable_1" name="enable_toolpack" pack_name="TOOLPACK_NAME"></%FUNCTAG%> 2. You MUST wait for the success result message (<%RESULTTAG% callId="tp_enable_1" status="success">...</%RESULTTAG%>) in the next user turn *before* attempting to use any functions from that toolpack. Do not call functions from an enabling toolpack in the same turn you enable it. Wait for the confirmation. Available toolpacks (use 'enable_toolpack' to activate): %TOOLPACKS%`;