chore: format & fix prettierignore

This commit is contained in:
2026-09-30 15:01:28 +02:00
parent 5153cc4f17
commit ca51f660ad
3 changed files with 580 additions and 562 deletions
+1
View File
@@ -1,3 +1,4 @@
.venv/
scripts/fzf.js
scripts/fuzzysort.js
scripts/settings-indexer.js
+1 -1
View File
@@ -33,4 +33,4 @@ class Llm : public ConfigObject {
: ConfigObject(parent), m_appearance(new LlmAppearance(this)) {}
};
}
} // namespace ZShell::config
+50 -33
View File
@@ -159,7 +159,13 @@ def _behaviour_for(text):
return "normal"
_TOOL_MODES = ("tool_call", "tool_call_duo", "tool_call_some", "tool_call_many", "tool_call_unknown")
_TOOL_MODES = (
"tool_call",
"tool_call_duo",
"tool_call_some",
"tool_call_many",
"tool_call_unknown",
)
def _tool_call_delta(index, call_id=None, name=None, arguments=None):
@@ -191,11 +197,7 @@ def _stream_tool_calls(w, cid, reasoning, calls):
w(_sse(_chunk(cid, _tool_call_delta(i, call_id=call_id, name=name))))
time.sleep(0.05)
for fragment in arguments:
w(
_sse(
_chunk(cid, _tool_call_delta(i, arguments=fragment))
)
)
w(_sse(_chunk(cid, _tool_call_delta(i, arguments=fragment))))
time.sleep(0.05)
w(_sse(_chunk(cid, {}, finish_reason="tool_calls")))
w(_sse(_usage_chunk(cid, 24, len(reasoning or []) + len(calls) * 2)))
@@ -294,9 +296,7 @@ class Handler(BaseHTTPRequestHandler):
def _send_loading_error(self):
# llama.cpp middleware: server not ready -> 503 on every route.
self._send_json(
503, _error(503, "Loading model", "unavailable_error")
)
self._send_json(503, _error(503, "Loading model", "unavailable_error"))
def _not_ready(self):
with _state_lock:
@@ -346,7 +346,10 @@ class Handler(BaseHTTPRequestHandler):
return self._send_loading_error()
with _state_lock:
no_models = _state["no_models"]
data = [] if no_models else [
data = (
[]
if no_models
else [
{
"id": MODEL_ID,
"object": "model",
@@ -354,6 +357,7 @@ class Handler(BaseHTTPRequestHandler):
"owned_by": "mock",
}
]
)
return self._send_json(200, {"object": "list", "data": data})
if path == "/":
return self._send_json(200, {"status": "ok", "mock": True})
@@ -445,7 +449,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "os-release\"}"],
['{"path": "/etc/', 'os-release"}'],
)
]
reasoning = [
@@ -457,7 +461,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "hostname\"}"],
['{"path": "/etc/', 'hostname"}'],
),
(
"call_mock_2",
@@ -468,14 +472,16 @@ class Handler(BaseHTTPRequestHandler):
],
),
]
reasoning = ["Two independent tool calls, ",
"batched together."]
reasoning = [
"Two independent tool calls, ",
"batched together.",
]
elif mode == "tool_call_some":
calls = [
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "hostname\"}"],
['{"path": "/etc/', 'hostname"}'],
),
(
"call_mock_2",
@@ -488,7 +494,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_3",
"readfile",
['{"path": "/etc/', "os-release\"}"],
['{"path": "/etc/', 'os-release"}'],
),
(
"call_mock_4",
@@ -501,7 +507,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_5",
"readfile",
['{"path": "/proc/', "uptime\"}"],
['{"path": "/proc/', 'uptime"}'],
),
(
"call_mock_6",
@@ -512,14 +518,16 @@ class Handler(BaseHTTPRequestHandler):
],
),
]
reasoning = ["Two independent tool calls, ",
"batched together."]
reasoning = [
"Two independent tool calls, ",
"batched together.",
]
elif mode == "tool_call_many":
calls = [
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "hostname\"}"],
['{"path": "/etc/', 'hostname"}'],
),
(
"call_mock_2",
@@ -532,7 +540,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_3",
"readfile",
['{"path": "/etc/', "os-release\"}"],
['{"path": "/etc/', 'os-release"}'],
),
(
"call_mock_4",
@@ -545,7 +553,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_5",
"readfile",
['{"path": "/proc/', "uptime\"}"],
['{"path": "/proc/', 'uptime"}'],
),
(
"call_mock_6",
@@ -558,7 +566,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "hostname\"}"],
['{"path": "/etc/', 'hostname"}'],
),
(
"call_mock_2",
@@ -571,7 +579,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_3",
"readfile",
['{"path": "/etc/', "os-release\"}"],
['{"path": "/etc/', 'os-release"}'],
),
(
"call_mock_4",
@@ -584,7 +592,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_5",
"readfile",
['{"path": "/proc/', "uptime\"}"],
['{"path": "/proc/', 'uptime"}'],
),
(
"call_mock_6",
@@ -597,7 +605,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_1",
"readfile",
['{"path": "/etc/', "hostname\"}"],
['{"path": "/etc/', 'hostname"}'],
),
(
"call_mock_2",
@@ -610,7 +618,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_3",
"readfile",
['{"path": "/etc/', "os-release\"}"],
['{"path": "/etc/', 'os-release"}'],
),
(
"call_mock_4",
@@ -623,7 +631,7 @@ class Handler(BaseHTTPRequestHandler):
(
"call_mock_5",
"readfile",
['{"path": "/proc/', "uptime\"}"],
['{"path": "/proc/', 'uptime"}'],
),
(
"call_mock_6",
@@ -634,8 +642,10 @@ class Handler(BaseHTTPRequestHandler):
],
),
]
reasoning = ["Two independent tool calls, ",
"batched together."]
reasoning = [
"Two independent tool calls, ",
"batched together.",
]
else: # tool_call_unknown
calls = [
(
@@ -665,7 +675,10 @@ class Handler(BaseHTTPRequestHandler):
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": content},
"message": {
"role": "assistant",
"content": content,
},
"finish_reason": "stop",
}
],
@@ -678,14 +691,18 @@ class Handler(BaseHTTPRequestHandler):
)
if mode == "error_during":
return self._stream(200, lambda w: _stream_error_during(w, cid, words))
return self._stream(
200, lambda w: _stream_error_during(w, cid, words)
)
if mode == "no_done":
return self._stream(200, lambda w: _stream_no_done(w, cid, words))
return self._stream(200, lambda w: _stream_normal(w, cid, words))
def log_message(self, format, *args):
# Compact single-line logging to stdout.
print("%s - %s" % (self.log_date_time_string(), format % args), flush=True)
print(
"%s - %s" % (self.log_date_time_string(), format % args), flush=True
)
def main():