Commit graph

16 commits

Author SHA1 Message Date
Snider
fbb58486c4 feat(api): WithChatCompletions option + bug fixes in chat_completions
- options.go: new WithChatCompletions(resolver) and
  WithChatCompletionsPath(path); api.New(...) now auto-mounts at
  /v1/chat/completions when a resolver is configured (previously the
  resolver could be attached but never mounted, which would have
  panicked Gin)
- chat_completions.go: fixed missing net/http import, dropped
  ModelType during discovery, Retry-After header set after c.JSON
  silently lost, swapped OpenAI error type/code fields, swapped
  validate call site, redundant nil check, builder length read before
  nil-receiver check
- openapi.go: effective*Path helpers surface an explicit path even
  when the corresponding Enabled flag is false so CLI callers still
  get x-*-path extensions; /swagger always in authentik public paths
- chat_completions_test.go: Good/Bad/Ugly coverage for new options,
  validation, no-resolver behaviour
- openapi_test.go: fix stale assertion for CacheEnabled-gated X-Cache
- go.mod: bump dappco.re/go/core/cli to v0.5.2
- Removed local go-io / go-log stubs — replace points to outer
  modules for single source of truth
- Migrated forge.lthn.ai/core/cli imports to dappco.re/go/core/cli
  across cmd/api/*.go + docs

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 14:34:51 +01:00
Snider
7bcb6d469c fix(pr#2): address CodeRabbit round 4 — newCacheStore fail-closed for unbounded cache
Prevent silent unbounded cache creation when both maxEntries and maxBytes
are non-positive: newCacheStore now returns nil, WithCacheLimits skips
middleware registration, and WithCache defaults to 1 000-entry LRU cap
when called with only a TTL argument.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-07 11:32:28 +01:00
Virgil
4725b39049 docs(api): align cache docs with explicit limits
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 08:36:59 +00:00
Virgil
085c57a06d feat(cache): add byte-bounded eviction
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 01:49:36 +00:00
Virgil
bb7d88f3ce feat(openapi): add external docs metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:47:38 +00:00
Virgil
4d7f3a9f99 feat(openapi): add terms of service metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:44:01 +00:00
Virgil
071de51bb5 feat(openapi): mark deprecated operations in spec
Expose route-level deprecation in generated OpenAPI operations and cover it with a regression test.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:40:53 +00:00
Virgil
b2d3c96ed7 feat(api): expose swagger licence metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:26:55 +00:00
Virgil
cd4e24d15f feat(api): document custom success statuses 2026-04-01 20:04:34 +00:00
Virgil
0ed72c4952 feat(api): document explicit route parameters
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 19:12:51 +00:00
Virgil
862604dc22 feat(api): expose SDK spec metadata flags
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 19:09:59 +00:00
Virgil
90600aa434 feat(api): expose swagger server metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:07:16 +00:00
Virgil
e713fb9f56 feat(api): emit rate limit headers on success and reject
Adds X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset to successful responses and 429 rejections, and documents the headers in OpenAPI.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:01:09 +00:00
Virgil
c4cbd018ac feat(api): auto-attach request metadata
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 14:00:04 +00:00
Virgil
6fdd769212 feat(api): add per-IP rate limiting middleware
Adds a token-bucket WithRateLimit option that rejects excess requests with 429 Too Many Requests and a standard error envelope.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 06:54:58 +00:00
Snider
753812ad57 feat(api): merge go-api + php-api into polyglot repo
Go source at root level (Option B), PHP under src/php/.
Module path: forge.lthn.ai/core/api
Package name: lthn/api

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-14 10:03:29 +00:00