current ToolFunctionParameters and associated types supports only a
subset of the json schema spec. this means certain fields are dropped
from the schema. google/jsonschema-go supports the full draft-07/2020-12
keyword set and preserves unknown keywords but uses the native go map
which is unordered
vendor google/jsonschema-go and redefine map fields as
tailscale.com/types/mapx.OrderedMap. this uses mapx.OrderedMap instead
of internal/orderedmap because mapx.OrderedMap almost exactly matches
the signature we need while also _not_ implementing json.Marshaler and
json.Unmarshaler. this is important because wk8/go-ordered-map/v2 uses
encoding/json which by default escapes HTML characters such as `<`, `>`,
`&`
this change is the first of many changes that will migrate tools and
tool calls to using 1) jsonschema.Schema and 2) mapx.OrderedMap
hardErrCh will deadlock since forwardBatch is blocked on
computeStartedCh which never gets sent. since the response to
hardErrCh is to panic, just panic instead
this change updates how metrics are collected. until now, performance
metrics, specifically initial input processing and subsequent generation
durations, were collected by taking the timestamp when creating a new
sequence, the first token generation, and completing generation. the
processing duration is taken as first token generation sub sequence
creation while generation is taken as completing generation sub first
token generation.
while this approach is an accurate end-to-end metric of processing and
generation, it's not comparable to other tools which only measure the
active, i.e. decode, duration.
this change updates the metrics to only capture decode duration so it
can be more directly compared to other tools
the first call to http.ResponseWriter.Write implicitly calls WriteHeader
with http.StatusOK if it hasn't already been called. once WriteHeader
has been called, subsequent calls has no effect. Write is called when
JSON encoding progressUpdateJSON{}. calls to
http.ResponseWriter.WriteHeader after the first encode is useless and
produces a warning:
http: superfluous response.WriteHeader call from github.com/ollama/ollama/server/internal/registry.(*statusCodeRecorder).WriteHeader (server.go:77)