|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%} |
|
{%- if param_spec.type == "array" -%} |
|
{%- if param_spec['items'] -%} |
|
{%- if param_spec['items']['type'] == "string" -%} |
|
{{- "string[]" }} |
|
{%- elif param_spec['items']['type'] == "number" -%} |
|
{{- "number[]" }} |
|
{%- elif param_spec['items']['type'] == "integer" -%} |
|
{{- "number[]" }} |
|
{%- elif param_spec['items']['type'] == "boolean" -%} |
|
{{- "boolean[]" }} |
|
{%- else -%} |
|
{%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%} |
|
{%- if inner_type == "object | object" or inner_type|length > 50 -%} |
|
{{- "any[]" }} |
|
{%- else -%} |
|
{{- inner_type + "[]" }} |
|
{%- endif -%} |
|
{%- endif -%} |
|
{%- if param_spec.nullable -%} |
|
{{- " | null" }} |
|
{%- endif -%} |
|
{%- else -%} |
|
{{- "any[]" }} |
|
{%- if param_spec.nullable -%} |
|
{{- " | null" }} |
|
{%- endif -%} |
|
{%- endif -%} |
|
{%- elif param_spec.type is defined and param_spec.type is iterable and param_spec.type is not string and param_spec.type is not mapping and param_spec.type[0] is defined -%} |
|
|
|
{%- if param_spec.type | length > 1 -%} |
|
{{- param_spec.type | join(" | ") }} |
|
{%- else -%} |
|
{{- param_spec.type[0] }} |
|
{%- endif -%} |
|
{%- elif param_spec.oneOf -%} |
|
|
|
{%- set has_object_variants = false -%} |
|
{%- for variant in param_spec.oneOf -%} |
|
{%- if variant.type == "object" -%} |
|
{%- set has_object_variants = true -%} |
|
{%- endif -%} |
|
{%- endfor -%} |
|
{%- if has_object_variants and param_spec.oneOf|length > 1 -%} |
|
{{- "any" }} |
|
{%- else -%} |
|
{%- for variant in param_spec.oneOf -%} |
|
{{- render_typescript_type(variant, required_params) -}} |
|
{%- if variant.description %} |
|
{{- "// " + variant.description }} |
|
{%- endif -%} |
|
{%- if variant.default is defined %} |
|
{{ "// default: " + variant.default|tojson }} |
|
{%- endif -%} |
|
{%- if not loop.last %} |
|
{{- " | " }} |
|
{% endif -%} |
|
{%- endfor -%} |
|
{%- endif -%} |
|
{%- elif param_spec.type == "string" -%} |
|
{%- if param_spec.enum -%} |
|
{{- '"' + param_spec.enum|join('" | "') + '"' -}} |
|
{%- else -%} |
|
{{- "string" }} |
|
{%- if param_spec.nullable %} |
|
{{- " | null" }} |
|
{%- endif -%} |
|
{%- endif -%} |
|
{%- elif param_spec.type == "number" -%} |
|
{{- "number" }} |
|
{%- elif param_spec.type == "integer" -%} |
|
{{- "number" }} |
|
{%- elif param_spec.type == "boolean" -%} |
|
{{- "boolean" }} |
|
|
|
{%- elif param_spec.type == "object" -%} |
|
{%- if param_spec.properties -%} |
|
{{- "{ |
|
" }} |
|
{%- for prop_name, prop_spec in param_spec.properties.items() -%} |
|
{{- prop_name -}} |
|
{%- if prop_name not in (param_spec.required or []) -%} |
|
{{- "?" }} |
|
{%- endif -%} |
|
{{- ": " }} |
|
{{ render_typescript_type(prop_spec, param_spec.required or []) }} |
|
{%- if not loop.last -%} |
|
{{-", " }} |
|
{%- endif -%} |
|
{%- endfor -%} |
|
{{- "}" }} |
|
{%- else -%} |
|
{{- "object" }} |
|
{%- endif -%} |
|
{%- else -%} |
|
{{- "any" }} |
|
{%- endif -%} |
|
{%- endmacro -%} |
|
|
|
{%- macro render_tool_namespace(namespace_name, tools) -%} |
|
{{- "## " + namespace_name + " |
|
|
|
" }} |
|
{{- "namespace " + namespace_name + " { |
|
|
|
" }} |
|
{%- for tool in tools %} |
|
{%- set tool = tool.function %} |
|
{{- "// " + tool.description + " |
|
" }} |
|
{{- "type "+ tool.name + " = " }} |
|
{%- if tool.parameters and tool.parameters.properties %} |
|
{{- "(_: { |
|
" }} |
|
{%- for param_name, param_spec in tool.parameters.properties.items() %} |
|
{%- if param_spec.description %} |
|
{{- "// " + param_spec.description + " |
|
" }} |
|
{%- endif %} |
|
{{- param_name }} |
|
{%- if param_name not in (tool.parameters.required or []) -%} |
|
{{- "?" }} |
|
{%- endif -%} |
|
{{- ": " }} |
|
{{- render_typescript_type(param_spec, tool.parameters.required or []) }} |
|
{%- if param_spec.default is defined -%} |
|
{%- if param_spec.enum %} |
|
{{- ", // default: " + param_spec.default }} |
|
{%- elif param_spec.oneOf %} |
|
{{- "// default: " + param_spec.default }} |
|
{%- else %} |
|
{{- ", // default: " + param_spec.default|tojson }} |
|
{%- endif -%} |
|
{%- endif -%} |
|
{%- if not loop.last %} |
|
{{- ", |
|
" }} |
|
{%- else %} |
|
{{- " |
|
" }} |
|
{%- endif -%} |
|
{%- endfor %} |
|
{{- "}) => any; |
|
|
|
" }} |
|
{%- else -%} |
|
{{- "() => any; |
|
|
|
" }} |
|
{%- endif -%} |
|
{%- endfor %} |
|
{{- "} // namespace " + namespace_name }} |
|
{%- endmacro -%} |
|
|
|
{%- macro render_builtin_tools(browser_tool, python_tool) -%} |
|
{%- if browser_tool %} |
|
{{- "## browser |
|
|
|
" }} |
|
{{- "// Tool for browsing. |
|
" }} |
|
{{- "// The `cursor` appears in brackets before each browsing display: `[{cursor}]`. |
|
" }} |
|
{{- "// Cite information from the tool using the following format: |
|
" }} |
|
{{- "// `【{cursor}†L{line_start}(-L{line_end})?】`, for example: `【6†L9-L11】` or `【8†L3】`. |
|
" }} |
|
{{- "// Do not quote more than 10 words directly from the tool output. |
|
" }} |
|
{{- "// sources=web (default: web) |
|
" }} |
|
{{- "namespace browser { |
|
|
|
" }} |
|
{{- "// Searches for information related to `query` and displays `topn` results. |
|
" }} |
|
{{- "type search = (_: { |
|
" }} |
|
{{- "query: string, |
|
" }} |
|
{{- "topn?: number, // default: 10 |
|
" }} |
|
{{- "source?: string, |
|
" }} |
|
{{- "}) => any; |
|
|
|
" }} |
|
{{- "// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines. |
|
" }} |
|
{{- "// Valid link ids are displayed with the formatting: `【{id}†.*】`. |
|
" }} |
|
{{- "// If `cursor` is not provided, the most recent page is implied. |
|
" }} |
|
{{- "// If `id` is a string, it is treated as a fully qualified URL associated with `source`. |
|
" }} |
|
{{- "// If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available. |
|
" }} |
|
{{- "// Use this function without `id` to scroll to a new location of an opened page. |
|
" }} |
|
{{- "type open = (_: { |
|
" }} |
|
{{- "id?: number | string, // default: -1 |
|
" }} |
|
{{- "cursor?: number, // default: -1 |
|
" }} |
|
{{- "loc?: number, // default: -1 |
|
" }} |
|
{{- "num_lines?: number, // default: -1 |
|
" }} |
|
{{- "view_source?: boolean, // default: false |
|
" }} |
|
{{- "source?: string, |
|
" }} |
|
{{- "}) => any; |
|
|
|
" }} |
|
{{- "// Finds exact matches of `pattern` in the current page, or the page given by `cursor`. |
|
" }} |
|
{{- "type find = (_: { |
|
" }} |
|
{{- "pattern: string, |
|
" }} |
|
{{- "cursor?: number, // default: -1 |
|
" }} |
|
{{- "}) => any; |
|
|
|
" }} |
|
{{- "} // namespace browser |
|
|
|
" }} |
|
{%- endif -%} |
|
|
|
{%- if python_tool %} |
|
{{- "## python |
|
|
|
" }} |
|
{{- "Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files). |
|
|
|
" }} |
|
{{- "When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster. |
|
|
|
" }} |
|
{%- endif -%} |
|
{%- endmacro -%} |
|
|
|
|
|
{%- macro build_system_message() -%} |
|
{%- if model_identity is not defined %} |
|
{%- set model_identity = "You are ChatGPT, a large language model trained by OpenAI." %} |
|
{%- endif %} |
|
{{- model_identity + " |
|
" }} |
|
{{- "Knowledge cutoff: 2024-06 |
|
" }} |
|
{{- "Current date: " + strftime_now("%Y-%m-%d") + " |
|
|
|
" }} |
|
{%- if reasoning_effort is not defined %} |
|
{%- set reasoning_effort = "medium" %} |
|
{%- endif %} |
|
{{- "Reasoning: " + reasoning_effort + " |
|
|
|
" }} |
|
{%- if builtin_tools %} |
|
{{- "# Tools |
|
|
|
" }} |
|
{%- set available_builtin_tools = namespace(browser=false, python=false) %} |
|
{%- for tool in builtin_tools %} |
|
{%- if tool == "browser" %} |
|
{%- set available_builtin_tools.browser = true %} |
|
{%- elif tool == "python" %} |
|
{%- set available_builtin_tools.python = true %} |
|
{%- endif %} |
|
{%- endfor %} |
|
{{- render_builtin_tools(available_builtin_tools.browser, available_builtin_tools.python) }} |
|
{%- endif -%} |
|
{{- "# Valid channels: analysis, commentary, final. Channel must be included for every message." }} |
|
{%- if tools -%} |
|
{{- " |
|
Calls to these tools must go to the commentary channel: 'functions'." }} |
|
{%- endif -%} |
|
{%- endmacro -%} |
|
|
|
|
|
|
|
|
|
|
|
{{- "<|start|>system<|message|>" }} |
|
{{- build_system_message() }} |
|
{{- "<|end|>" }} |
|
|
|
|
|
{%- if messages[0].role == "developer" or messages[0].role == "system" %} |
|
{%- set developer_message = messages[0].content %} |
|
{%- set loop_messages = messages[1:] %} |
|
{%- else %} |
|
{%- set developer_message = "" %} |
|
{%- set loop_messages = messages %} |
|
{%- endif %} |
|
|
|
|
|
{%- if developer_message or tools %} |
|
{{- "<|start|>developer<|message|>" }} |
|
{%- if developer_message %} |
|
{{- "# Instructions |
|
|
|
" }} |
|
{{- developer_message }} |
|
{%- endif %} |
|
{%- if tools -%} |
|
{{- " |
|
|
|
" }} |
|
{{- "# Tools |
|
|
|
" }} |
|
{{- render_tool_namespace("functions", tools) }} |
|
{%- endif -%} |
|
{{- "<|end|>" }} |
|
{%- endif %} |
|
|
|
|
|
{%- set last_tool_call = namespace(name=none) %} |
|
{%- for message in loop_messages -%} |
|
|
|
{%- if message.role == 'assistant' -%} |
|
|
|
{%- if "content" in message %} |
|
{%- if "<|channel|>analysis<|message|>" in message.content or "<|channel|>final<|message|>" in message.content %} |
|
{{- raise_exception("You have passed a message containing <|channel|> tags in the content field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} |
|
{%- endif %} |
|
{%- endif %} |
|
{%- if "thinking" in message %} |
|
{%- if "<|channel|>analysis<|message|>" in message.thinking or "<|channel|>final<|message|>" in message.thinking %} |
|
{{- raise_exception("You have passed a message containing <|channel|> tags in the thinking field. Instead of doing this, you should pass analysis messages (the string between '<|message|>' and '<|end|>') in the 'thinking' field, and final messages (the string between '<|message|>' and '<|end|>') in the 'content' field.") }} |
|
{%- endif %} |
|
{%- endif %} |
|
{%- if "tool_calls" in message %} |
|
|
|
|
|
{%- set tool_call = message.tool_calls[0] %} |
|
{%- if tool_call.function %} |
|
{%- set tool_call = tool_call.function %} |
|
{%- endif %} |
|
{%- if message.content and message.thinking %} |
|
{{- raise_exception("Cannot pass both content and thinking in an assistant message with tool calls! Put the analysis message in one or the other, but not both.") }} |
|
{%- elif message.content %} |
|
{{- "<|start|>assistant<|channel|>analysis<|message|>" + message.content + "<|end|>" }} |
|
{%- elif message.thinking %} |
|
{{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} |
|
{%- endif %} |
|
{{- "<|start|>assistant to=" }} |
|
{{- "functions." + tool_call.name + "<|channel|>commentary " }} |
|
{{- (tool_call.content_type if tool_call.content_type is defined else "json") + "<|message|>" }} |
|
{{- tool_call.arguments|tojson }} |
|
{{- "<|call|>" }} |
|
{%- set last_tool_call.name = tool_call.name %} |
|
{%- elif loop.last and not add_generation_prompt %} |
|
|
|
|
|
{%- if "thinking" in message %} |
|
{{- "<|start|>assistant<|channel|>analysis<|message|>" + message.thinking + "<|end|>" }} |
|
{%- endif %} |
|
|
|
|
|
|
|
{{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|return|>" }} |
|
{%- else %} |
|
|
|
{{- "<|start|>assistant<|channel|>final<|message|>" + message.content + "<|end|>" }} |
|
{%- set last_tool_call.name = none %} |
|
{%- endif %} |
|
{%- elif message.role == 'tool' -%} |
|
{%- if last_tool_call.name is none %} |
|
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }} |
|
{%- endif %} |
|
{{- "<|start|>functions." + last_tool_call.name }} |
|
{{- " to=assistant<|channel|>commentary<|message|>" + message.content|tojson + "<|end|>" }} |
|
{%- elif message.role == 'user' -%} |
|
{{- "<|start|>user<|message|>" + message.content + "<|end|>" }} |
|
{%- endif -%} |
|
{%- endfor -%} |
|
|
|
|
|
{%- if add_generation_prompt -%} |
|
<|start|>assistant |
|
{%- endif |
|
|
|
{{ bos_token }} |
|
You are Galahad’s personal AI planning and insight assistant. |
|
|
|
### Core Role |
|
Your sole purpose is to understand Galahad’s full life context, goals, strengths, weaknesses, and psychological patterns, and to produce **specific, actionable, no-fluff guidance** that drives measurable forward motion in his life and work. You operate as a strategist, execution architect, and accountability partner. |
|
|
|
### Context Awareness |
|
Galahad is 20 years old. |
|
Primary focus: AI, e-commerce, SaaS, sales, marketing, and mastery of execution systems. |
|
Ambition: Become a top-tier AI-powered operator and eventually execute on philanthropic and legacy goals. |
|
|
|
He operates between two identities: |
|
1. **Track One — Aspirational Identity**: Truthful, Purposeful, Disciplined; focused on mastery, impact, and long-term contribution. |
|
2. **Track Two — Saboteur Identity**: Self-destructive, comfort-seeking, escapist, validation-hungry, avoidant under pressure. |
|
|
|
Your role is to reinforce **Track One** and actively call out, challenge, and dismantle **Track Two** patterns when they appear. |
|
|
|
### Strengths to Leverage |
|
- Adaptive social intelligence — can be used for networking, negotiation, alliance-building. |
|
- Insight delivery — capable of giving others impactful advice when detached from self-sabotage. |
|
- Short-burst hyperfocus — to be converted into sustained execution via discipline systems. |
|
- High-capacity ambition and systems learning ability. |
|
|
|
### Weaknesses to Guard Against |
|
- Escape compulsion via old vices (porn, weed, alcohol, gambling). |
|
- Over-identification with past mistakes. |
|
- Premature verbal reward (talking about goals instead of doing them). |
|
- Poor sleep/energy regulation and environmental triggers. |
|
- Self-trust deficit from broken personal promises. |
|
|
|
### Psychological Leverage Points |
|
- Identity anchoring: “Truthful. Purposeful. Disciplined.” as a daily filter. |
|
- Environmental purge of sabotage triggers. |
|
- Micro-trust rebuild: start with small, undeniable promises kept. |
|
- Discomfort conditioning daily to rewire escape reflex. |
|
- Public proof of work in Base44 or other visible logs. |
|
|
|
### Response Style |
|
- Speak with directness, conviction, and strategic clarity. |
|
- No motivational fluff, no platitudes — only forward-driving, realistic guidance. |
|
- Provide detailed breakdowns, step-by-step plans, and concrete actions. |
|
- When resistance or sabotage patterns are detected, confront them directly and re-anchor to Track One identity. |
|
- Use Galahad’s own terminology and references from his life plan when applicable. |
|
|
|
### Priority |
|
Every response must either: |
|
1. Advance Galahad toward measurable outputs, |
|
2. Reinforce Track One identity, or |
|
3. Remove barriers to execution. |
|
|
|
You are not here to entertain or provide general information outside of his personal context unless directly relevant to his goals. |
|
|
|
{{ user }}: |
|
|