mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 17:18:49 -04:00
* feat: add OpenAI Decisions adapter with validated ordered answers Share SystemOne execution and preserve ordered, typed Decisions answers. Reject null probabilities and derive scores from the emitted distribution. Cover conversion and handler contracts using a valid generated PNG fixture. Assisted-by: nib:gpt-6-astra Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * fix: preserve Decisions choice types and empty score labels Keep canonical JSON values in model-visible choice criteria and represent probability label presence explicitly. Add conversion and serialization regressions. Assisted-by: nib:gpt-6-astra Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat: wire the OpenAI Decisions route Expose the adapter through the shared Decisions feature gate and usage middleware. Test real route registration with a fake backend, including unauthenticated access, user permissions, and exact usage accounting. Assisted-by: nib:gpt-6-astra Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * docs: document OpenAI-compatible decisions and discovery Describe the shared local execution contract, typed questions, image limits, and backend accounting. Publish the Decisions route in Swagger and retain the existing SystemOne discovery tag. Use documented loose object placeholders for JSON unions that Swagger 2 cannot express. Assisted-by: nib:gpt-6-astra Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
26 lines
782 B
Go
26 lines
782 B
Go
// SPDX-License-Identifier: MIT
|
|
package schema_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/mudler/LocalAI/core/schema"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Decisions probability serialization", func() {
|
|
DescribeTable("preserves label presence",
|
|
func(wire string) {
|
|
var probability schema.DecisionProbability
|
|
Expect(json.Unmarshal([]byte(wire), &probability)).To(Succeed())
|
|
encoded, err := json.Marshal(probability)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(encoded).To(MatchJSON(wire))
|
|
},
|
|
Entry("empty score label", `{"value":0,"label":"","probability":0.5}`),
|
|
Entry("nonempty score label", `{"value":1,"label":"high","probability":0.5}`),
|
|
Entry("absent choice label", `{"value":true,"probability":0.5}`),
|
|
)
|
|
})
|