refactor: Remove project rules

This commit is contained in:
Petr Mironychev
2026-06-11 13:36:23 +02:00
parent 2c9475cddf
commit 05fe38e289
45 changed files with 1333 additions and 299 deletions

View File

@@ -3,8 +3,17 @@
"role": {{ tojson(msg.role) }},
"content": [
{% for b in msg.content_blocks %}
{% if b.type == "image" %}{% include "partials/anthropic_image.jinja" %}
{% else %}{{ tojson(b) }},
{% if b.type == "text" %}
{ "type": "text", "text": {{ tojson(b.text) }} },
{% else if b.type == "thinking" %}
{ "type": "thinking", "thinking": {{ tojson(b.thinking) }}, "signature": {{ tojson(b.signature) }} },
{% else if b.type == "redacted_thinking" %}
{ "type": "redacted_thinking", "data": {{ tojson(b.data) }} },
{% else if b.type == "tool_use" %}
{ "type": "tool_use", "id": {{ tojson(b.id) }}, "name": {{ tojson(b.name) }}, "input": {{ tojson(b.input) }} },
{% else if b.type == "tool_result" %}
{ "type": "tool_result", "tool_use_id": {{ tojson(b.tool_use_id) }}, "content": {{ tojson(b.content) }} },
{% else if b.type == "image" %}{% include "partials/anthropic_image.jinja" %}
{% endif %}
{% endfor %}
]

View File

@@ -2,15 +2,36 @@
{ "role": "system", "content": {{ tojson(ctx.system_prompt) }} },
{% endif %}
{% for msg in ctx.history %}
{
"role": {{ tojson(msg.role) }},
"content": {{ tojson(msg.content) }}
{% if existsIn(msg, "images") %}
, "images": [
{% for img in msg.images %}
{{ tojson(img.data) }},
{% set tcalls = filter_by_type(msg.content_blocks, "tool_use") %}
{% set tresults = filter_by_type(msg.content_blocks, "tool_result") %}
{% if length(tresults) > 0 %}
{% for b in tresults %}
{
"role": "tool",
"content": {{ tojson(b.content) }}
{% if b.name != "" %}
, "tool_name": {{ tojson(b.name) }}
{% endif %}
},
{% endfor %}
]
{% else %}
{
"role": {{ tojson(msg.role) }},
"content": {{ tojson(msg.content) }}
{% if length(tcalls) > 0 %}
, "tool_calls": [
{% for b in tcalls %}
{ "type": "function", "function": { "name": {{ tojson(b.name) }}, "arguments": {{ tojson(b.input) }} } },
{% endfor %}
]
{% endif %}
{% if existsIn(msg, "images") %}
, "images": [
{% for img in msg.images %}
{{ tojson(img.data) }},
{% endfor %}
]
{% endif %}
},
{% endif %}
},
{% endfor %}

View File

@@ -1,7 +1,7 @@
{% set tcalls = filter_by_type(msg.content_blocks, "tool_use") %}
{
"role": "assistant",
"content": {{ tojson(msg.content) }}
"content": {% if msg.content != "" %}{{ tojson(msg.content) }}{% else %}null{% endif %}
{% if length(tcalls) > 0 %}
, "tool_calls": [
{% for b in tcalls %}

View File

@@ -1,11 +1,12 @@
[
{ "type": "text", "text": {{ tojson(msg.content) }} }
{% if msg.content != "" %}
{ "type": "text", "text": {{ tojson(msg.content) }} },
{% endif %}
{% for img in msg.images %}
,
{% if img.is_url %}
{ "type": "image_url", "image_url": { "url": {{ tojson(img.data) }} } }
{ "type": "image_url", "image_url": { "url": {{ tojson(img.data) }} } },
{% else %}
{ "type": "image_url", "image_url": { "url": "data:{{ img.media_type }};base64,{{ img.data }}" } }
{ "type": "image_url", "image_url": { "url": "data:{{ img.media_type }};base64,{{ img.data }}" } },
{% endif %}
{% endfor %}
]