Repository navigation
Expand file tree
/
Copy pathtest_jina
More file actions
executable file
·50 lines (41 loc) · 1.61 KB
/
Copy pathtest_jina
File metadata and controls
executable file
·50 lines (41 loc) · 1.61 KB
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
#!/usr/bin/env bash
set -u
source "$HOME/dotfiles/bin/src/capture.bash"
readonly ollama_url="${OLLAMA_URL:-http://127.0.0.1:11434}"
readonly model="${CODESCAN_JINA_MODEL:-jina-code-embeddings:1.5b}"
readonly expected_dim="${CODESCAN_JINA_DIM:-1536}"
fail() {
printf 'FAIL local Ollama Jina acceptance: %s\n' "$1" >&2
exit 1
}
require_tool() {
command -v "$1" >/dev/null 2>&1 || fail "required tool is unavailable: $1"
}
require_tool curl
require_tool jq
out=
err=
rc=
readonly show_payload="$(jq -cn --arg model "$model" '{model: $model}')"
capture curl -fsS \
-H 'Content-Type: application/json' \
-d "$show_payload" \
"$ollama_url/api/show"
if [ "$rc" -ne 0 ]; then
fail "Ollama does not advertise local model '$model'"
fi
printf '%s' "$out" | jq -e '.capabilities | index("embedding") != null' >/dev/null || \
fail "Ollama classifies '$model' as non-embedding"
readonly embed_payload="$(jq -cn --arg model "$model" '{model: $model, input: ["local semantic code embedding probe"]}')"
capture curl -fsS \
-H 'Content-Type: application/json' \
-d "$embed_payload" \
"$ollama_url/api/embed"
if [ "$rc" -ne 0 ]; then
fail "Ollama rejected a local embedding request for '$model'"
fi
actual_model="$(printf '%s' "$out" | jq -r '.model // empty')"
actual_dim="$(printf '%s' "$out" | jq -r '.embeddings[0] | length')"
[ "$actual_model" = "$model" ] || fail "Ollama returned model '$actual_model', expected '$model'"
[ "$actual_dim" = "$expected_dim" ] || fail "Ollama returned $actual_dim dimensions, expected $expected_dim"
printf 'PASS local Ollama Jina acceptance: %s returned %s-dimensional embeddings\n' "$model" "$actual_dim"