MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / StreamChat

Method StreamChat

api/client.go:644–678  ·  view source on GitHub ↗
(
	ctx context.Context,
	systemPrompt string,
	messages []map[string]any,
	tools []map[string]any,
	options *LLMRequestOptions,
)

Source from the content-addressed store, hash-verified

642func (c *OpenAICompatibleClient) buildMessages(systemPrompt string, messages []map[string]any) []map[string]any {
643 converted := convertAnthropicMessagesToOpenAI(messages)
644 result := make([]map[string]any, 0, len(converted)+1)
645
646 if systemPrompt != "" {
647 result = append(result, map[string]any{
648 "role": "system",
649 "content": systemPrompt,
650 })
651 }
652
653 result = append(result, converted...)
654 return result
655}
656
657func (c *OpenAICompatibleClient) Complete(
658 ctx context.Context,
659 systemPrompt string,
660 messages []map[string]any,
661 opts CompleteOptions,
662) (string, error) {
663 response, err := collectCompletionStream(c.StreamChat(ctx, systemPrompt, messages, opts.Tools,
664 &LLMRequestOptions{MaxTokens: opts.MaxTokens, Temperature: opts.Temperature}))
665 if err != nil {
666 return "", err
667 }
668 return response.Text, nil
669}
670
671func (c *OpenAICompatibleClient) CompleteStructured(
672 ctx context.Context,
673 systemPrompt string,
674 messages []map[string]any,
675 opts StructuredCompletionOptions,
676) (Response, error) {
677 return collectCompletionStream(c.StreamChat(ctx, systemPrompt, messages, opts.Tools, &LLMRequestOptions{
678 MaxTokens: opts.MaxTokens, RequiredTool: opts.RequiredTool, DisableThinking: opts.DisableThinking,
679 Temperature: opts.Temperature,
680 }))
681}

Callers

nothing calls this directly

Calls 6

chatCompletionsURLMethod · 0.95
buildHeadersMethod · 0.95
buildMessagesMethod · 0.95
AnthropicToolsToOpenAIFunction · 0.85
singleErrorEventFunction · 0.85
RetryWithBackoffFunction · 0.85

Tested by

no test coverage detected