Skip to content
Draft

pr 4 #26110

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 50 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ type Options struct {
SSHConfig codersdk.SSHConfigResponse

HTTPClient *http.Client
// ChatSubscribeFn provides cross-replica subscription merging.
// Set by enterprise for HA deployments. Nil in AGPL single-replica.
ChatSubscribeFn chatd.SubscribeFn
// ChatStreamPartsDialer dials remote chat stream parts.
// Set by enterprise for HA deployments. Nil uses chatd's local
// in-process channel dialer.
ChatStreamPartsDialer chatd.StreamPartsDialer
// ChatProviderAPIKeys overrides deployment-derived provider keys.
// Test harnesses use this to route chat models to local providers.
ChatProviderAPIKeys *chatprovider.ProviderAPIKeys
Expand Down Expand Up @@ -816,7 +817,7 @@ func New(options *Options) *API {
Logger: options.Logger.Named("chatd"),
Database: options.Database,
ReplicaID: api.ID,
SubscribeFn: options.ChatSubscribeFn,
StreamPartsDialer: options.ChatStreamPartsDialer,
MaxChatsPerAcquire: int32(maxChatsPerAcquire), //nolint:gosec // maxChatsPerAcquire is clamped to int32 range above.
ProviderAPIKeys: providerAPIKeys,
AllowBYOK: options.DeploymentValues.AI.BridgeConfig.AllowBYOK.Value(),
Expand Down Expand Up @@ -1340,6 +1341,7 @@ func New(options *Options) *API {
r.Get("/prompts", api.getChatUserPrompts)
r.Route("/stream", func(r chi.Router) {
r.Get("/", api.streamChat)
r.Get("/parts", api.streamChatParts)
r.Get("/desktop", api.watchChatDesktop)
r.Get("/git", api.watchChatGit)
})
Expand Down
20 changes: 20 additions & 0 deletions coderd/exp_chats.go
Original file line number Diff line number Diff line change
Expand Up @@ -7958,3 +7958,23 @@ func (api *API) getChatDebugRun(rw http.ResponseWriter, r *http.Request) {

httpapi.Write(ctx, rw, http.StatusOK, db2sdk.ChatDebugRunDetail(run, steps))
}

// EXPERIMENTAL: this endpoint is experimental and is subject to change.
//
// @Summary Stream chat parts via WebSockets
// @ID stream-chat-parts-via-websockets
// @Security CoderSessionToken
// @Tags Chats
// @Produce json
// @Param chat path string true "Chat ID" format(uuid)
// @Success 200 {object} codersdk.ChatStreamEvent
// @Router /api/experimental/chats/{chat}/stream/parts [get]
// @x-apidocgen {"skip": true}
// @Description Experimental: this endpoint is subject to change.
func (api *API) streamChatParts(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
chat := httpmw.ChatParam(r)
if err := api.chatDaemon.ServeStreamPartsAuthorized(rw, r, chat); err != nil {
api.Logger.Named("chat_stream_parts").Debug(ctx, "chat stream parts closed", slog.Error(err))
}
}
56 changes: 0 additions & 56 deletions coderd/pubsub/chatstreamnotify.go

This file was deleted.

Loading
Loading