fixed trying to index response with status instead of statusCode

This commit is contained in:
2025-10-16 00:34:55 -06:00
parent c84e3a0700
commit c376f1f474

View File

@@ -235,6 +235,8 @@ function xai.create(api_key: string)
local client = {}
function client:completions(request: CompletionsRequest): SuccessfulApiResponse | FailedApiResponse
request.stream = false
local config = {
url = `{baseUrl}/chat/completions`,
method = "POST",
@@ -249,7 +251,7 @@ function xai.create(api_key: string)
local decoded: CompletionsResponse = serde.decode("json", response.body)
return { success = true, response = decoded } :: SuccessfulApiResponse
else
return { success = false, status = response.status, message = response.body } :: FailedApiResponse
return { success = false, status = response.statusCode, message = response.body } :: FailedApiResponse
end
end
@@ -266,7 +268,7 @@ function xai.create(api_key: string)
local decoded: ModelsResponse = serde.decode("json", response.body)
return { success = true, response = decoded } :: SuccessfulApiResponse
else
return { success = false, status = response.status, message = response.body } :: FailedApiResponse
return { success = false, status = response.statusCode, message = response.body } :: FailedApiResponse
end
end
@@ -283,7 +285,7 @@ function xai.create(api_key: string)
local decoded: ModelResponse = serde.decode("json", response.body)
return { success = true, response = decoded } :: SuccessfulApiResponse
else
return { success = false, status = response.status, message = response.body } :: FailedApiResponse
return { success = false, status = response.statusCode, message = response.body } :: FailedApiResponse
end
end
@@ -300,7 +302,7 @@ function xai.create(api_key: string)
local decoded: LanguageModelsResponse = serde.decode("json", response.body)
return { success = true, response = decoded } :: SuccessfulApiResponse
else
return { success = false, status = response.status, message = response.body } :: FailedApiResponse
return { success = false, status = response.statusCode, message = response.body } :: FailedApiResponse
end
end
@@ -317,7 +319,7 @@ function xai.create(api_key: string)
local decoded: LanguageModelResponse = serde.decode("json", response.body)
return { success = true, response = decoded } :: SuccessfulApiResponse
else
return { success = false, status = response.status, message = response.body } :: FailedApiResponse
return { success = false, status = response.statusCode, message = response.body } :: FailedApiResponse
end
end