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