Add a new llm service that proxies chat-completion requests from AI web extensions to a configured OpenAI-compatible endpoint, replacing the standalone Node.js sidecar. It is part of the oCIS single binary, opt-in via OCIS_ADD_RUN_SERVICES=llm, and exposed through the proxy at POST /graph/v1beta1/extensions/org.libregraph/llm/chat/completions. Authentication is delegated to oCIS. Requests are rate-limited per user with a sliding window backed by the shared store, and the request body is sanitized before forwarding. Streaming requests are rejected. Signed-off-by: Lukas Hirt <info@hirt.cz>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
// services/llm/pkg/command/version.go
|
|
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/olekukonko/tablewriter"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
|
"github.com/owncloud/ocis/v2/services/llm/pkg/config"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Version prints the service versions of all running instances.
|
|
func Version(cfg *config.Config) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "version",
|
|
Usage: "print the version of this binary and the running service instances",
|
|
Category: "info",
|
|
Action: func(c *cli.Context) error {
|
|
fmt.Println("Version: " + version.GetString())
|
|
fmt.Printf("Compiled: %s\n", version.Compiled())
|
|
fmt.Println("")
|
|
|
|
reg := registry.GetRegistry()
|
|
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
|
|
if err != nil {
|
|
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
|
|
return err
|
|
}
|
|
|
|
if len(services) == 0 {
|
|
fmt.Println("No running " + cfg.Service.Name + " service found.")
|
|
return nil
|
|
}
|
|
|
|
table := tablewriter.NewTable(os.Stdout)
|
|
table.Header("Version", "Address", "Id")
|
|
for _, s := range services {
|
|
for _, n := range s.Nodes {
|
|
table.Append([]string{s.Version, n.Address, n.Id})
|
|
}
|
|
}
|
|
table.Render()
|
|
return nil
|
|
},
|
|
}
|
|
}
|