(client tls_client.HttpClient, api_request groq.APIRequest, api_key string, organization string, proxy string)
| 93 | return base64.StdEncoding.EncodeToString([]byte(prefix)) |
| 94 | } |
| 95 | func ChatCompletions(client tls_client.HttpClient, api_request groq.APIRequest, api_key string, organization string, proxy string) (*http.Response, error) { |
| 96 | if proxy != "" { |
| 97 | client.SetProxy(proxy) |
| 98 | } |
| 99 | body_json, _ := json.Marshal(api_request) |
| 100 | header := baseHeader() |
| 101 | header.Set("authorization", "Bearer "+api_key) |
| 102 | header.Set("groq-app", "chat") |
| 103 | header.Set("groq-organization", organization) |
| 104 | //response, err := client.Request("POST", "https://api.groq.com/openai/v1/chat/completions", header, nil, bytes.NewBuffer(body_json)) |
| 105 | req, err := http.NewRequest(http.MethodPost, "https://api.groq.com/openai/v1/chat/completions", bytes.NewBuffer(body_json)) |
| 106 | req.Header = header |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | response, err := client.Do(req) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | if response.StatusCode != 200 { |
| 115 | |
| 116 | return nil, errors.New("response status code is not 200") |
| 117 | } |
| 118 | return response, nil |
| 119 | } |
| 120 | func GetModels(client tls_client.HttpClient, api_key string, organization string, proxy string) (*http.Response, error) { |
| 121 | header := baseHeader() |
| 122 | header.Set("authorization", "Bearer "+api_key) |
nothing calls this directly
no test coverage detected