MCPcopy
hub / github.com/mudler/LocalAI / ListModels

Method ListModels

core/cli/chat/client.go:29–43  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

27}
28
29func (c *localAIChatClient) ListModels(ctx context.Context) ([]string, error) {
30 resp, err := c.client.ListModels(ctx)
31 if err != nil {
32 return nil, err
33 }
34
35 models := make([]string, 0, len(resp.Models))
36 for _, model := range resp.Models {
37 if model.ID != "" {
38 models = append(models, model.ID)
39 }
40 }
41 sort.Strings(models)
42 return models, nil
43}
44
45func (c *localAIChatClient) StreamChat(ctx context.Context, model string, messages []chatMessage, out io.Writer) (string, error) {
46 stream, err := c.client.CreateChatCompletionStream(ctx, openai.ChatCompletionRequest{

Callers

nothing calls this directly

Calls 1

ListModelsMethod · 0.65

Tested by

no test coverage detected