package main import ( "bytes" "encoding/json" "io" "net/http" "strings" "github.com/gofiber/fiber/v2" ) var DeepseekErrorCodes map[string]string func init() { DeepseekErrorCodes = make(map[string]string) DeepseekErrorCodes["400"] = "Provider error: Invalid Request - Please contact the support." DeepseekErrorCodes["401"] = "Provider error: Invalid Authentication - Ensure that the API key is still valid." DeepseekErrorCodes["402"] = "Provider error: You have run out of balance. Please check your account's balance." DeepseekErrorCodes["422"] = "Provider error: Request exceeds the maximum allowed number of bytes." DeepseekErrorCodes["429"] = "Provider error: Your account has hit a rate limit. You are sending requests too quickly." DeepseekErrorCodes["500"] = "Provider error: An unexpected error has occurred internal to Deepseek’s systems." DeepseekErrorCodes["503"] = "Provider error: Deepseek’s server is temporarily overloaded." } func RequestDeepseek(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) url := "https://api.deepseek.com/chat/completions" 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 .