MCPcopy Index your code
hub / github.com/docker/docker-agent / pickDefaultModel

Function pickDefaultModel

examples/chat/main.go:116–125  ·  view source on GitHub ↗

pickDefaultModel queries /v1/models and returns the first agent name the server advertises.

(ctx context.Context, client *openai.Client)

Source from the content-addressed store, hash-verified

114// pickDefaultModel queries /v1/models and returns the first agent name
115// the server advertises.
116func pickDefaultModel(ctx context.Context, client *openai.Client) (string, error) {
117 page, err := client.Models.List(ctx)
118 if err != nil {
119 return "", err
120 }
121 if len(page.Data) == 0 {
122 return "", errors.New("server exposes no models")
123 }
124 return page.Data[0].ID, nil
125}
126
127// chat sends the conversation to the server, prints the assistant's reply
128// to stdout (streaming if requested) and returns the final assembled

Callers 1

runFunction · 0.85

Calls 2

ListMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected