MCPcopy
hub / github.com/wavetermdev/waveterm / runAIChatStep

Function runAIChatStep

pkg/aiusechat/usechat.go:181–188  ·  view source on GitHub ↗
(ctx context.Context, sseHandler *sse.SSEHandlerCh, backend UseChatBackend, chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse)

Source from the content-addressed store, hash-verified

179}
180
181func runAIChatStep(ctx context.Context, sseHandler *sse.SSEHandlerCh, backend UseChatBackend, chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse) (*uctypes.WaveStopReason, []uctypes.GenAIMessage, error) {
182 if chatOpts.Config.APIType == uctypes.APIType_OpenAIResponses && shouldUseChatCompletionsAPI(chatOpts.Config.Model) {
183 return nil, nil, fmt.Errorf("Chat completions API not available (must use newer OpenAI models)")
184 }
185 stopReason, messages, rateLimitInfo, err := backend.RunChatStep(ctx, sseHandler, chatOpts, cont)
186 updateRateLimit(rateLimitInfo)
187 return stopReason, messages, err
188}
189
190func getUsage(msgs []uctypes.GenAIMessage) uctypes.AIUsage {
191 var rtn uctypes.AIUsage

Callers 1

RunAIChatFunction · 0.85

Calls 3

updateRateLimitFunction · 0.85
RunChatStepMethod · 0.65

Tested by

no test coverage detected