File size: 2,563 Bytes
768a8d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Patch frontend ChatInput.tsx: add 3 new OpenRouter models to the model picker.

New models (openai/ prefix routes to OpenRouter):
  - UPSTAGE Solar Pro 4 (openai/upstage/solar-pro4)
  - NVIDIA Nemotron 3.5 Lightning:free (openai/nvidia/nemotron-3.5-lightning:free)
  - Liquid LFM 2.5 2.6B:free (openai/liquid/lfm-2.5-2.6b:free)
"""

import os

FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"

def patch():
    if not os.path.exists(FILE):
        print(f"SKIP: {FILE} not found")
        return

    with open(FILE, "r", encoding="utf-8") as f:
        content = f.read()

    if "upstage-solar-pro4" in content:
        print("OK: models already present")
        return

    # Unique anchor: the deepseek-v4-flash-latest entry inside DEFAULT_MODEL_OPTIONS.
    # Insert the 3 new model objects immediately BEFORE that entry.
    anchor = "  {\n    id: 'deepseek-v4-flash-latest',\n"
    new_entries = (
        "  {\n"
        "    id: 'upstage-solar-pro4',\n"
        "    name: 'UPSTAGE Solar Pro 4',\n"
        "    modelPath: 'openai/upstage/solar-pro4',\n"
        "    avatarUrl: 'https://huggingface.co/api/avatars/upstage',\n"
        "    recommended: true,\n"
        "  },\n"
        "  {\n"
        "    id: 'nemotron-3.5-lightning',\n"
        "    name: 'NVIDIA Nemotron 3.5 Lightning:free',\n"
        "    modelPath: 'openai/nvidia/nemotron-3.5-lightning:free',\n"
        "    avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n"
        "    recommended: true,\n"
        "  },\n"
        "  {\n"
        "    id: 'liquid-lfm-2.5-2.6b',\n"
        "    name: 'Liquid LFM 2.5 2.6B:free',\n"
        "    modelPath: 'openai/liquid/lfm-2.5-2.6b:free',\n"
        "    avatarUrl: 'https://huggingface.co/api/avatars/liquid',\n"
        "    recommended: true,\n"
        "  },\n"
    )

    if anchor in content:
        content = content.replace(anchor, new_entries + anchor, 1)
        print("OK: added 3 new models before deepseek-v4-flash-latest entry")
    else:
        # Fallback: find the deepseek id line by itself.
        alt = "    id: 'deepseek-v4-flash-latest',\n"
        if alt in content:
            content = content.replace(alt, new_entries + "  {\n" + alt, 1)
            print("OK: added 3 new models (fallback anchor)")
        else:
            print("FAIL: could not find insertion anchor in DEFAULT_MODEL_OPTIONS")
            return

    with open(FILE, "w", encoding="utf-8") as f:
        f.write(content)
    print("OK: ChatInput.tsx new models patched")


if __name__ == "__main__":
    patch()