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

Method Complete

api/client.go:608–642  ·  view source on GitHub ↗
(
	ctx context.Context,
	systemPrompt string,
	messages []map[string]any,
	opts CompleteOptions,
)

Source from the content-addressed store, hash-verified

606 out <- EventResult{Event: map[string]any{"type": "stop_reason", "stop_reason": stopReason}}
607 }
608 return true
609 })
610 if err != nil {
611 out <- EventResult{Err: err}
612 }
613 }()
614
615 return out
616}
617
618type OpenAICompatibleClient struct {
619 LLMClientBase
620}
621
622var _ LLMClient = (*OpenAICompatibleClient)(nil)
623
624func (c *OpenAICompatibleClient) buildHeaders() map[string]string {
625 return map[string]string{
626 "Authorization": "Bearer " + c.APIKey,
627 "Content-Type": "application/json",
628 }
629}
630
631func (c *OpenAICompatibleClient) chatCompletionsURL() string {
632 baseURL := strings.TrimRight(c.BaseURL, "/")
633 if strings.HasSuffix(baseURL, "/chat/completions") {
634 return baseURL
635 }
636 if strings.HasSuffix(baseURL, "/v1") {
637 baseURL = strings.TrimSuffix(baseURL, "/v1")
638 }
639 return baseURL + "/chat/completions"
640}
641
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

Callers

nothing calls this directly

Calls 7

chatCompletionsURLMethod · 0.95
buildHeadersMethod · 0.95
buildMessagesMethod · 0.95
AnthropicToolsToOpenAIFunction · 0.85
doJSONRequestFunction · 0.85
getStringFunction · 0.85
RetryRequestMethod · 0.80

Tested by

no test coverage detected