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

Function doRawJSONRequest

api/client.go:950–968  ·  view source on GitHub ↗
(
	ctx context.Context,
	httpClient *http.Client,
	method string,
	url string,
	headers map[string]string,
	body []byte,
)

Source from the content-addressed store, hash-verified

948 case "usage":
949 response.InputTokens = getInt(event, "input_tokens")
950 response.CacheReadInputTokens = getInt(event, "cache_read_input_tokens")
951 response.CacheCreationInputTokens = getInt(event, "cache_creation_input_tokens")
952 response.OutputTokens = getInt(event, "output_tokens")
953 case "stop_reason":
954 response.StopReason = getString(event, "stop_reason")
955 case "error":
956 return Response{}, completionStreamError(event)
957 }
958 }
959 response.Text = text.String()
960 return response, nil
961}
962
963func completionStreamError(event map[string]any) error {
964 message := strings.TrimSpace(getString(event, "message"))
965 if message == "" {
966 message = "streaming completion failed"
967 }
968 statusCode := getInt(event, "status_code")
969 if statusCode > 0 {
970 statusErr := NewAPIStatusError(getString(event, "provider"), statusCode,
971 getString(event, "status"), []byte(getString(event, "raw_error")))

Callers 3

streamAnthropicMethod · 0.85
doJSONRequestFunction · 0.85

Calls 2

DoMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected