mirror of
https://github.com/mudler/LocalAI.git
synced 2026-04-29 03:24:49 -04:00
* chore: add golangci-lint with new-from-merge-base baseline
Configure golangci-lint v2 with the standard linter set (errcheck, govet,
ineffassign, unused) plus forbidigo, which enforces the Ginkgo/Gomega-only
test convention from .agents/coding-style.md by rejecting stdlib testing
calls (t.Errorf, t.Fatalf, t.Run, ...). staticcheck is disabled — the
codebase has many pre-existing QF-style suggestions not worth gating on.
issues.new-from-merge-base = master makes the lint job a gate for new
issues only; the ~1300 pre-existing baseline stays visible via
'make lint-all' for incremental cleanup. CI runs 'make lint'.
Backends needing C/C++ headers we don't install in the lint runner are
excluded via a deny list in the Makefile (backend/go/{piper,silero-vad,
llm}, cmd/launcher). Discovery still flows through 'go list ./...', so
new packages are scanned automatically.
To make backend/go/{sam3-cpp,stablediffusion-ggml,whisper} typecheckable,
move their .cpp/.h sources into cpp/ subdirs (matching qwen3-tts-cpp /
acestep-cpp). Without this 'go list' rejects the package because Go does
not allow .cpp alongside .go without cgo.
Fix two real bugs found by lint in tests/integration/ (run only via
'make test-stores', not default CI): a stale zerolog reference left over
from the slog migration (c37785b7) and an unused 'os' import.
Assisted-by: Claude Code:Opus 4.7 (1M) [Bash] [Read] [Edit] [Write]
Signed-off-by: Richard Palethorpe <io@richiejp.com>
* ci(lint): generate proto sources and fetch full history
The lint job was failing for two reasons:
- pkg/grpc/proto/*.go is generated, not checked in. Several packages
import it, so without 'make protogen-go' typecheck fails project-wide
with "no required module provides package github.com/mudler/LocalAI/
pkg/grpc/proto".
- golangci-lint's new-from-merge-base needs to git-merge-base the PR
against master, but actions/checkout's default shallow clone doesn't
fetch master. fetch-depth: 0 brings full history; the config now
references origin/master (the remote-tracking branch that survives
the shallow checkout) instead of bare master (which doesn't exist
locally after checkout).
Assisted-by: Claude Code:Opus 4.7 (1M) [Bash] [Read] [Edit] [Write]
Signed-off-by: Richard Palethorpe <io@richiejp.com>
* ci(lint): stub react-ui/dist for go:embed glob
core/http/app.go has //go:embed react-ui/dist/*. The glob must match at
least one non-hidden entry or typecheck fails the whole core/http
package. We don't need the real React bundle to lint Go code, so just
touch an empty index.html to satisfy the embed.
Assisted-by: Claude Code:Opus 4.7 (1M) [Bash] [Read] [Edit] [Write]
Signed-off-by: Richard Palethorpe <io@richiejp.com>
---------
Signed-off-by: Richard Palethorpe <io@richiejp.com>
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
#ifndef GOSAM3_H
|
|
#define GOSAM3_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Load model from file. Returns 0 on success, non-zero on failure.
|
|
int sam3_cpp_load_model(const char *model_path, int threads);
|
|
|
|
// Encode an image from file path. Must be called before segmentation.
|
|
// Returns 0 on success.
|
|
int sam3_cpp_encode_image(const char *image_path);
|
|
|
|
// Segment with point/box prompts (PVS mode).
|
|
// points: flat array of [x, y, label] triples (label: 1=positive, 0=negative)
|
|
// boxes: flat array of [x1, y1, x2, y2] quads
|
|
// Returns number of detections, or -1 on error.
|
|
int sam3_cpp_segment_pvs(float *points, int n_point_triples,
|
|
float *boxes, int n_box_quads,
|
|
float threshold);
|
|
|
|
// Segment with text prompt (PCS mode, SAM 3 only).
|
|
// Returns number of detections, or -1 on error.
|
|
int sam3_cpp_segment_pcs(const char *text_prompt, float threshold);
|
|
|
|
// Access detection results (valid after a segment call).
|
|
int sam3_cpp_get_n_detections(void);
|
|
|
|
// Get bounding box for detection i (as x, y, width, height).
|
|
float sam3_cpp_get_detection_x(int i);
|
|
float sam3_cpp_get_detection_y(int i);
|
|
float sam3_cpp_get_detection_w(int i);
|
|
float sam3_cpp_get_detection_h(int i);
|
|
|
|
// Get confidence score for detection i.
|
|
float sam3_cpp_get_detection_score(int i);
|
|
|
|
// Get mask as PNG-encoded bytes.
|
|
// If buf is NULL, returns the required buffer size.
|
|
// Otherwise writes up to buf_size bytes and returns bytes written.
|
|
int sam3_cpp_get_detection_mask_png(int i, unsigned char *buf, int buf_size);
|
|
|
|
// Free current detection results.
|
|
void sam3_cpp_free_results(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // GOSAM3_H
|