package main import ( "bytes" "encoding/json" "io" "net/http" "strings" "github.com/gofiber/fiber/v2" ) var GroqErrorCodes map[string]string func init() { GroqErrorCodes = make(map[string]string) GroqErrorCodes["400"] = "Provider error: Invalid Request - Please contact the support." GroqErrorCodes["404"] = "Provider error: The requested resource could not be found. Most likely the model is not available anymore." GroqErrorCodes["422"] = "Provider error: The request was well-formed but could not be followed due to semantic errors. Verify the data provided for correctness and completeness." GroqErrorCodes["429"] = "Provider error: Too many requests were sent in a given timeframe. Implement request throttling and respect rate limits." GroqErrorCodes["500"] = "Provider error: A generic error occurred on Gorq's server. Try the request again later or contact support if the issue persists." GroqErrorCodes["502"] = "Provider error: The server received an invalid response from an upstream server. This may be a temporary issue; retrying the request might resolve it." GroqErrorCodes["503"] = "Provider error: The server is not ready to handle the request, often due to maintenance or overload. Wait before retrying the request." } func RequestGroq(c *fiber.Ctx, llm LLM, messages []Message, testApiKey string) string { model := llm.Model.ModelID temperature := float64(llm.Temperature) context := llm.Context maxTokens := int(llm.MaxToken) var apiKey string if testApiKey == "" { err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(edgeCtx, ` with filtered_keys := ( select Key { key } filter .company.name = $0 AND .