MCPcopy
hub / github.com/docker/docker-agent / runChatCommand

Method runChatCommand

cmd/root/chat.go:61–98  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

59}
60
61func (f *chatFlags) runChatCommand(cmd *cobra.Command, args []string) (commandErr error) {
62 ctx := cmd.Context()
63 telemetry.TrackCommand(ctx, "serve", append([]string{"chat"}, args...))
64 defer func() { // do not inline this defer so that commandErr is not resolved early
65 telemetry.TrackCommandError(ctx, "serve", append([]string{"chat"}, args...), commandErr)
66 }()
67
68 out := cli.NewPrinter(cmd.OutOrStdout())
69 agentFilename := args[0]
70
71 ln, cleanup, err := newListener(ctx, f.listenAddr)
72 if err != nil {
73 return err
74 }
75 defer cleanup()
76
77 out.Println("Listening on", ln.Addr().String())
78 out.Println("OpenAI-compatible chat completions endpoint: http://" + ln.Addr().String() + "/v1/chat/completions")
79
80 apiKey := f.apiKey
81 if f.apiKeyEnv != "" {
82 if v := os.Getenv(f.apiKeyEnv); v != "" {
83 apiKey = v
84 }
85 }
86
87 return chatserver.Run(ctx, agentFilename, chatserver.Options{
88 AgentName: f.agentName,
89 RunConfig: &f.runConfig,
90 CORSOrigin: f.corsOrigin,
91 APIKey: apiKey,
92 MaxRequestBytes: f.maxRequestSize,
93 RequestTimeout: f.requestTimeout,
94 ConversationsMaxSessions: f.conversationsMaxItems,
95 ConversationTTL: f.conversationTTL,
96 MaxIdleRuntimes: f.maxIdleRuntimes,
97 }, ln)
98}

Callers

nothing calls this directly

Calls 8

PrintlnMethod · 0.95
TrackCommandFunction · 0.92
TrackCommandErrorFunction · 0.92
NewPrinterFunction · 0.92
RunFunction · 0.92
newListenerFunction · 0.85
ContextMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected