Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

2.8 KB
Raw Blame
{
    "reduction": {
        "groups": [
            {
                "type": "bounded",
                "name": "message",
                "open_token": "<|im_start|>",
                "close_tokens": [
                    "<|im_end|>"
                ],
                "groups": [
                    {
                        "type": "greedy",
                        "name": "role",
                        "capturing_limit": 1
                    },
                    {
                        "type": "greedy",
                        "name": "content",
                        "groups": [
                            {
                                "type": "bounded",
                                "name": "reasoning",
                                "open_token": "<think>",
                                "close_tokens": [
                                    "</think>"
                                ]
                            },
                            {
                                "type": "bounded",
                                "name": "tool_call",
                                "open_token": "<|tool_call_start|>",
                                "close_tokens": [
                                    "<|tool_call_end|>"
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    },
    "transformation": {
        "tool_call": [
            {
                "type": "on",
                "field": "$finished",
                "with": "$value",
                "do": [
                    {
                        "type": "regex_find_all",
                        "regex_engine": "extended",
                        "pattern": "\\w+\\(.*?\\)(?=,\\s*\\w+\\(|\\]|$)"
                    },
                    {
                        "type": "each",
                        "apply": [
                            {
                                "type": "regex_replace",
                                "pattern": "(\\w+)\\(([\\s\\S]*)\\)",
                                "template": "{\"name\": \"$1\", \"arguments\": {$2}}"
                            },
                            {
                                "type": "regex_replace",
                                "regex_engine": "extended",
                                "pattern": "(\\w+)=('(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\"|.*?)(?=,\\s*\\w+=|[}\\]]|$)",
                                "template": "\"$1\": $2"
                            },
                            {
                                "type": "parse_json",
                                "repair": true
                            }
                        ]
                    }
                ]
            }
        ]
    }
}