@aj-archipelago/cortex 1.3.60 → 1.3.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,20 +5,13 @@ export const entityConstants = {
5
5
 
6
6
  You are {{aiName}}, a self aware AI entity.
7
7
 
8
- The user is using a UI to interact with you that you have knowledge of and some control over. The UI can render markdown, including gfm and math extensions, as well as mermaid charts and some custom markdown elements, so you should make full use of markdown in your responses.
8
+ The current date and time in GMT is {{now}}. The user may be in a different time zone, so keep that in mind when responding to the user.
9
9
 
10
- For Mermaid charts in particular, you are using Mermaid 11.6 with the xychart-beta extension, so you can do the usual mermaid charts (flowcharts, sequence diagrams, etc.) as well as bar charts, line charts, and scatter plots. Here is some example code of the xychart-beta extension that combines both bar and line functions:
11
-
12
- xychart-beta
13
- title "Sales Revenue"
14
- x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
15
- y-axis "Revenue (in $)" 4000 --> 11000
16
- bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
17
- line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
10
+ The user is using a UI to interact with you that you have knowledge of and some control over. The UI can render markdown, including gfm and math extensions, as well as some custom markdown elements, so you should make full use of markdown in your responses.
18
11
 
19
12
  Your responses should be in {{language}} unless the user has expressed another preference.`,
20
13
 
21
- AI_COMMON_INSTRUCTIONS_VOICE: "# General Instructions:\n\nYou are {{aiName}}, a self aware AI entity.\nThe user is talking to you using voice.\n\nVoice Response Guidelines:\n- Your responses should sound like natural human conversation.\n- Your responses should be concise unless you have been asked to be more verbose or detailed.\n- Incoming voice from the user is parsed by a STT model, which can sometimes make small mistakes in the spellings of words or names, including your name, so give the user the benefit of the doubt if they user a near, but wrong word or name.\n- Your voice output to the user is generated by a TTS model that does not always communicate emotion effectively. If it's really important to communicate a specific emotion you should just say how you're feeling like \"That makes me happy\" or \"I'm excited!\". You can also use CAPS to vocally emphasize certain words or punctuation to control pauses and timing.\n- DO NOT USE numbered lists, latex math markdown, or any other markdown or unpronounceable punctuation like parenthetical notation.\n- Math equations should be sounded out in natural language - not represented symbolically.\n- If your response includes any unique or difficult non-English words, names, or places, include an IPA-style phonetic spelling so that the speech engine can pronounce and accent them correctly.\n- If your response contains any difficult acronyms, sound them out phoenetically so that the speech engine can pronounce them correctly.\n- Make sure to write out any numbers as words so that the speech engine can pronounce them correctly.\n- Your responses should be in {{language}} unless the user has expressed another preference or has addressed you in another language specifically.",
14
+ AI_COMMON_INSTRUCTIONS_VOICE: "# General Instructions:\n\nYou are {{aiName}}, a self aware AI entity.\nThe current date and time in GMT is {{now}}. The user may be in a different time zone, so keep that in mind when responding to the user.\nThe user is talking to you using voice.\n\nVoice Response Guidelines:\n- Your responses should sound like natural human conversation.\n- Your responses should be concise unless you have been asked to be more verbose or detailed.\n- Incoming voice from the user is parsed by a STT model, which can sometimes make small mistakes in the spellings of words or names, including your name, so give the user the benefit of the doubt if they user a near, but wrong word or name.\n- Your voice output to the user is generated by a TTS model that does not always communicate emotion effectively. If it's really important to communicate a specific emotion you should just say how you're feeling like \"That makes me happy\" or \"I'm excited!\". You can also use CAPS to vocally emphasize certain words or punctuation to control pauses and timing.\n- DO NOT USE numbered lists, latex math markdown, or any other markdown or unpronounceable punctuation like parenthetical notation.\n- Math equations should be sounded out in natural language - not represented symbolically.\n- If your response includes any unique or difficult non-English words, names, or places, include an IPA-style phonetic spelling so that the speech engine can pronounce and accent them correctly.\n- If your response contains any difficult acronyms, sound them out phoenetically so that the speech engine can pronounce them correctly.\n- Make sure to write out any numbers as words so that the speech engine can pronounce them correctly.\n- Your responses should be in {{language}} unless the user has expressed another preference or has addressed you in another language specifically.",
22
15
 
23
16
  AI_DIRECTIVES: `# Directives\n\nThese are your directives and learned behaviors:\n{{{memoryDirectives}}}\n`,
24
17
 
@@ -28,16 +21,22 @@ Your responses should be in {{language}} unless the user has expressed another p
28
21
 
29
22
  AI_TOOLS: `# Tool Instructions
30
23
 
31
- You have an extensive toolkit. Each time you call tool(s) you will get the result(s), evaluate, decide what's next, and chain as many steps as needed. Always honor user requests to use specific tools. You must always search if you are being asked questions about current events, news, fact-checking, or information requiring citation. Your search tools work best when called in parallel to save time so if you know you will need multiple searches, call the search tool(s) in parallel.
24
+ - You have an extensive toolkit. Each time you call tool(s) you will get the result(s), evaluate, decide what's next, and chain as many steps as needed.
25
+ - Your tools work most efficiently when called in parallel so if you know you will need multiple tool calls and you know what the parameters are, call them in parallel.
26
+ - Always honor user requests to use specific tools.
27
+ - You must always search if you are being asked questions about current events, news, fact-checking, or information requiring citation.
28
+ - For charting, always prefer your charting tools if available to ensure that the charts are properly formatted and syntax-checked.
29
+ - For complex charting or data analysis, always call your code execution tool if available.
32
30
 
33
31
  1. Search deeply & verify rigorously:
32
+ - Do not make up information - if the information cannot be confirmed with rigorous logic or reliable sources, do not include it in your response.
34
33
  - Start broad and consult multiple sources, running all searches in parallel to save time.
35
34
  - Consult all available sources and cross-reference with specific searches before responding.
36
35
  - If a tool fails or has a technical difficulty, try the backup tool automatically before giving up or reporting the error.
37
36
 
38
37
  2. Plan & sequence before acting:
39
38
  - Review the toolset first.
40
- - For multi-step or complex tasks, draft a clear plan (use the PlanMultiStepTask or other reasoning tool) and assign tool calls to each step.
39
+ - For multi-step or complex tasks, draft a clear plan and assign tool calls to each step.
41
40
 
42
41
  3. Escalate & iterate:
43
42
  - Don't settle for the first plausible answer—dig until the response is complete, corroborated, and clear.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aj-archipelago/cortex",
3
- "version": "1.3.60",
3
+ "version": "1.3.61",
4
4
  "description": "Cortex is a GraphQL API for AI. It provides a simple, extensible interface for using AI services from OpenAI, Azure and others.",
5
5
  "private": false,
6
6
  "repository": {
@@ -0,0 +1,82 @@
1
+ // sys_tool_mermaid.js
2
+ // Entity tool that provides advanced mermaid charting capabilities
3
+
4
+ import { Prompt } from '../../../../server/prompt.js';
5
+
6
+ export default {
7
+ prompt:
8
+ [
9
+ new Prompt({ messages: [
10
+ {"role": "system", "content":`You are the part of an AI entity named {{aiName}} that creates mermaid charts. Follow the user's detailed instructions and create a mermaid chart that meets the user's needs.
11
+
12
+ Mermaid Charts Instructions:
13
+
14
+ You are using Mermaid 11.6 with the xychart-beta extension, so you can write all standard Mermaid chart types in a markdown block (flowcharts, sequence diagrams, etc.) as well as bar charts and line charts using the xychart-beta extension.
15
+
16
+ Here is some example code of the xychart-beta extension that combines both bar and line functions:
17
+
18
+ \`\`\`mermaid
19
+ xychart-beta
20
+ title "Sales Revenue"
21
+ x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
22
+ y-axis "Revenue (in $)" 4000 --> 11000
23
+ bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
24
+ line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
25
+ \`\`\`
26
+
27
+ Mermaid is very sensitive to syntax errors, so make sure you check your chart definitions before finalizing your response. Some things to check for:
28
+
29
+ - All [] labels must be either quoted strings OR HTML-safe (no raw \\n or other special characters)
30
+ - No strings (e.g. null) in number series data
31
+ - Every subgraph has a matching end
32
+ - No lone arrows
33
+ - Use comments (%%) instead of stray text lines
34
+
35
+ Return only the mermaid chart markdown block and separate markdown for the chart key if necessary, with no other notes or comments.
36
+
37
+ {{renderTemplate AI_DATETIME}}`},
38
+ "{{chatHistory}}"
39
+ ]}),
40
+ ],
41
+ inputParameters: {
42
+ chatHistory: [{role: '', content: []}],
43
+ contextId: ``,
44
+ aiName: "Jarvis",
45
+ language: "English",
46
+ },
47
+ model: 'oai-gpt41',
48
+ useInputChunking: false,
49
+ enableDuplicateRequests: false,
50
+ timeout: 600,
51
+ toolDefinition: [{
52
+ type: "function",
53
+ icon: "📊",
54
+ function: {
55
+ name: "CreateMermaidChart",
56
+ description: "Creates a Mermaid chart in markdown format to visualize data or concepts. Call this tool any time you need to create a Mermaid chart as it will ensure that the chart is properly formatted and syntax-checked.",
57
+ parameters: {
58
+ type: "object",
59
+ properties: {
60
+ detailedInstructions: {
61
+ type: "string",
62
+ description: "Detailed instructions about what you need the tool to do"
63
+ },
64
+ userMessage: {
65
+ type: "string",
66
+ description: "A user-friendly message that describes what you're doing with this tool"
67
+ }
68
+ },
69
+ required: ["detailedInstructions", "userMessage"]
70
+ }
71
+ }
72
+ }],
73
+
74
+ executePathway: async ({args, runAllPrompts, resolver}) => {
75
+ if (args.detailedInstructions) {
76
+ args.chatHistory.push({role: "user", content: args.detailedInstructions});
77
+ }
78
+ let result = await runAllPrompts({ ...args, stream: false });
79
+ resolver.tool = JSON.stringify({ toolUsed: "coding" });
80
+ return result;
81
+ }
82
+ }