-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJustfile
More file actions
131 lines (109 loc) · 3.74 KB
/
Copy pathJustfile
File metadata and controls
131 lines (109 loc) · 3.74 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# llmproxy task runner
#
# Run `just --list` for available recipes.
image := "llmproxy"
port := "8080"
location := "global"
# Default: run tests
default: test
# Build in debug mode
build:
cargo build
# Build in release mode
build-release:
cargo build --release
# Run unit tests (fast, no binary startup)
test:
cargo test --workspace --lib --bins
# Run integration tests (starts the proxy binary, uses wiremock backends)
test-integration:
cargo test -p llmproxy-proxy --test integration
# Run all tests (unit + integration)
test-all: test test-integration
# Run clippy lints
clippy:
cargo clippy --workspace --all-targets -- -D warnings
# Format code
fmt:
cargo fmt --all
# Check formatting without modifying
fmt-check:
cargo fmt --all -- --check
# Full CI check: format, clippy, unit + integration tests
ci: fmt-check clippy test-all
# Build the container image
container-build:
podman build -t {{image}} .
# Smoke-test the container image (binary runs, prints help)
container-test: container-build
podman run --rm {{image}} --help
# Build integration test runner container
container-build-integration:
podman build --target integration-runner -t {{image}}-integration .
# Run integration tests in a container (no host toolchain required)
container-test-integration: container-build-integration
podman run --rm {{image}}-integration
# Run the proxy in a container (pass extra args/env as needed)
container-run *ARGS: container-build
podman run --rm -it \
--name llmproxy \
-p {{port}}:8080 \
-e RUST_LOG="${RUST_LOG:-info}" \
{{ARGS}} \
{{image}}
# Run with GCP Vertex AI (bind-mounts ~/.config/gcloud, needs GOOGLE_CLOUD_PROJECT + VERTEX_LOCATION)
container-run-vertex: container-build
podman run --rm -it \
--name llmproxy \
-p {{port}}:8080 \
-v ${HOME}/.config/gcloud:/gcp-creds:ro,z \
-e GOOGLE_APPLICATION_CREDENTIALS=/gcp-creds/application_default_credentials.json \
-e LLMPROXY_BACKEND=gcp-vertex \
-e GOOGLE_CLOUD_PROJECT="${GOOGLE_CLOUD_PROJECT}" \
-e VERTEX_LOCATION="{{location}}" \
-e RUST_LOG="${RUST_LOG:-info}" \
{{image}}
# Run the proxy locally with cargo (debug build)
run *ARGS:
cargo run -p llmproxy-proxy -- {{ARGS}}
# Run the proxy locally with the release binary
run-release *ARGS: build-release
./target/release/llmproxy {{ARGS}}
# Quick smoke test: hit the health endpoint
smoke-test:
curl -sf http://127.0.0.1:{{port}}/healthz | python3 -m json.tool
# Launch opencode through the proxy (assumes proxy is running on {{port}})
opencode-via-proxy *ARGS:
#!/usr/bin/env bash
set -euo pipefail
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
cat > "$tmpdir/opencode.json" <<EOF
{
"\$schema": "https://opencode.ai/config.json",
"autoupdate": false, "formatter": false, "lsp": false, "snapshot": false,
"permission": "allow",
"provider": {
"llmproxy": {
"npm": "@ai-sdk/openai-compatible",
"name": "llmproxy",
"options": { "baseURL": "http://127.0.0.1:{{port}}/v1" },
"models": { "claude-opus-4-6": { "name": "Claude Opus 4" } }
}
}
}
EOF
mkdir -p "$tmpdir/data/opencode"
echo '{"llmproxy":{"type":"api_key","token":"unused"}}' > "$tmpdir/data/opencode/auth.json"
OPENCODE_CONFIG="$tmpdir/opencode.json" \
XDG_DATA_HOME="$tmpdir/data" \
XDG_STATE_HOME="$tmpdir/data" \
opencode -m llmproxy/claude-opus-4-6 {{ARGS}}
# Copy the example config to get started
init:
@if [ -f llmproxy.toml ]; then \
echo "llmproxy.toml already exists"; \
else \
cp llmproxy.example.toml llmproxy.toml; \
echo "Created llmproxy.toml from example -- edit it for your environment."; \
fi