(cmd *cobra.Command, args []string)
| 59 | } |
| 60 | |
| 61 | func (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 | } |
nothing calls this directly
no test coverage detected